With this code we can create a bat file with a list of files in a folder.
On Error Resume Next
dim outfile
dim str
set fileobj=Createobject("Scripting.FileSystemObject")
objStartFolder = "."
Set objFolder = fileobj.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
set outfile=fileobj.opentextfile(objFolder.Path &"\script.bat",8,true)
i=0
For Each objFile in colFiles
If UCase(Right(objFile.Name, 4)) = ".DOC" Then
outfile.WriteLine("c:\some.exe " & chr(34) & objFile.Name & Chr(34) & " bla bla bla ")
i=i+1
End IF
Next
'outfile.WriteLine("total number of doc files = "&i)
outfile.close
If Err.number <> 0 Then
'Msgbox "Unexpected Error" & vbCrlF &vbCrLf & Err.Description
End If
On Error Resume Next
dim outfile
dim str
set fileobj=Createobject("Scripting.FileSystemObject")
objStartFolder = "."
Set objFolder = fileobj.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
set outfile=fileobj.opentextfile(objFolder.Path &"\script.bat",8,true)
i=0
For Each objFile in colFiles
If UCase(Right(objFile.Name, 4)) = ".DOC" Then
outfile.WriteLine("c:\some.exe " & chr(34) & objFile.Name & Chr(34) & " bla bla bla ")
i=i+1
End IF
Next
'outfile.WriteLine("total number of doc files = "&i)
outfile.close
If Err.number <> 0 Then
'Msgbox "Unexpected Error" & vbCrlF &vbCrLf & Err.Description
End If
Hello friends,
ReplyDeleteBAT are simple text documents that run sets of commands. When you open a batch file MS command runs the commands. Batch commands, like macros are useful for running a set of repetitive commands on a regular basis, reducing risk of human error. Window's inbuilt command runs batch files much like their original operation in MS-DOS. Thanks a lot....
Data Extract