This code will take all the .bat files in the current directory and make one .bat file called "myNewFile.Bat". Now even i am impressed that this works.
Code:Dim fs, f, f1, fc Dim myReadFile, myNewFile Dim strFileRead As String Set fs = CreateObject("Scripting.FileSystemObject") 'the new file made up of all the others Set myNewFile = fs.CreateTextFile("myNewFile.Bat", True) Set f = fs.GetFolder(CurDir) 'get a list of files Set fc = f.Files For Each f1 In fc 'if this is a .bat file If Right$(f1.Name, 3) = "bat" Then 'get the file Set myReadFile = fs.OpenTextFile(f1.Name, 1) 'loop to write each line While Not myReadFile.AtEndOfStream strFileRead = myReadFile.ReadLine myNewFile.WriteLine (strFileRead) Wend 'close file myReadFile.Close End If Next myNewFile.Close Set f = Nothing Set f1 = Nothing Set fc = Nothing Set fs = Nothing





Reply With Quote