Skip to content

Instantly share code, notes, and snippets.

@JoshMock
Created July 14, 2010 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshMock/475670 to your computer and use it in GitHub Desktop.
Save JoshMock/475670 to your computer and use it in GitHub Desktop.
Prints a list of file names in a given folder to a text file.
' Results: Prints a list of file names in FOLDER_TO_CHECK to the text file at OUTPUT_FILE_LOCATION
Dim FOLDER_TO_CHECK
FOLDER_TO_CHECK = "C:\Folder\to\list\"
OUTPUT_FILE_LOCATION = "C:\Temp\ListFileNames.txt"
Dim fs, logFile, folder
Set fs = CreateObject("Scripting.FileSystemObject")
Set logFile = fs.OpenTextFile(OUTPUT_FILE_LOCATION, 2)
Set folder = fs.GetFolder(FOLDER_TO_CHECK)
For Each file In folder.Files
logFile.WriteLine file.Name
Next
logFile.Close
Set folder = Nothing
Set logFile = Nothing
Set fs = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment