I have several hundred text files that I need to parse. I have
written the script to parse them, and am currently using an argument
so that I can simply drag and drop the file to be parsed on to the
script. I need a way to execute all the files at once without having
to do each one seperately.

For instance, If I have a folder called "Text Files" and inside that
folder resides 100 text files with the following naming comvention:

log1.txt
log2.txt
log3.txt
etc...

After parsing the files, the output is put in a file called "Text
Files Output"
and inside that folder will reside the output text files i.e.

log1_output.txt
log2_output.txt
log3_output.txt
etc...

Is there a way to execute a script for every text file in the folder
and create the proper output file names?

Thanks, I'm obviously new to VBSCript, but am having a great time
learning this language, but can't figure this little problem out.

Re:How to do batch processing on multiple files by Jimmy

Jimmy
Thu Dec 04 03:18:40 CST 2003

Hi,

>-----Original Message-----
>I have several hundred text files that I need to parse.
I have
>written the script to parse them, and am currently using
an argument
>so that I can simply drag and drop the file to be parsed
on to the
>script. I need a way to execute all the files at once
without having
>to do each one seperately.
>
>For instance, If I have a folder called "Text Files"
and inside that
>folder resides 100 text files with the following naming
comvention:
>
>log1.txt
>log2.txt
>log3.txt
>etc...
>
>After parsing the files, the output is put in a file
called "Text
>Files Output"
>and inside that folder will reside the output text files
i.e.
>
>log1_output.txt
>log2_output.txt
>log3_output.txt
>etc...
>
>Is there a way to execute a script for every text file
in the folder
>and create the proper output file names?
>
>Thanks, I'm obviously new to VBSCript, but am having a
great time
>learning this language, but can't figure this little
problem out.
>.
>

What you need is to have a controller script that call
the target script iteratively,

controller.vbs: (not tested)

temp = ShowFolderList("c:\data_folder") 'read the input
file name
s = split ( temp, VBCRLF) ' split into array

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

for i = 0 to ubound(s)

Set oExec = WshShell.Exec("cscript.exe target.vbs " & s
(i) & " " & s(i)&"_out" )

next

Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & VBCRLF
Next
ShowFolderList = s
End Function