...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem:
I need a Visual Basic Script file, call it "Move and Reformat Text File.VBS," that will run from a Windows Script Host command-prompt-based version as follows:
C:\> Cscript.exe "Move and Reformat Text File.VBS"
The objective of the VBScript file, "Move and Reformat Text File.VBS, is to move a text file from an input folder, "C:\Input\, to an output folder, "C:\Output\, but with all lines of the original file concatenated to a single string, and with a space inserted between the line elements.
For example, say, the input file is "C:\Input\1.TXT" and it contains the following lines:
Line_1
Line_2
. . .
Line_n
Then I want to create a corresponding output file "C:\Output\1.txt" that contains a single line, i.e., one string, as follows:
Line_1 Line_2 . . . Line_n
Note the single space inserted between each line.
After this is done, delete the input file, "1.TXT " from the "C:\Input\" folder.
Do this procedure for each *.TXT file in the input folder.
Also, sense when a new text file is added to the "C:\Input\" folder and run the procedure again. Or, if it is not feasible to program that, then at least invoke "Move and Reformat Text File.VBS" periodically, say, every five minutes.
In summary, here is the pseudo code outline of the procedure I envision:
For each text file in the input folder
- Create a new, blank, output text file of the same name as the input file.
- Save the new output text file in the output folder.
- Concatenate all the lines of the input file to one string.
- Append the concatenated string in the new output text file.
- Close the output text file.
- Delete the input text file.
Thanks for your help.
Start Free Trial