so I'm trying to write an easy vbs file that will take the contents of a directory and write them into a txt file... this part is easy, but for some reason, my code erases whatever was in the txt file before it was ran and I want it to just append to the end of the file... can someone please help?
On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder
Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\test"
If sFolder = "" Then
Wscript.Echo "No Folder parameter was passed"
Wscript.Quit
End If
Set NewFile = fso.CreateTextFile("c:\test1\FileList.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
For each folderIdx In files
NewFile.WriteLine(folderIdx.Name)
Next
NewFile.Close