Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to give a variable folder path?

Status
Not open for further replies.

Ruriko

Programmer
Aug 17, 2012
7
This script basically goes to a folder and list all the files in that folder and output it in a txt file. Now instead of defining the folder path I want it to use the txt file that contains a bunch of folder paths in it and I want to loop that txt file. How can I do this?

Code:
Dim fso
Dim ObjFolder
Dim ObjOutFile
Dim ObjFiles
Dim ObjFile

'Creating File System Object
Set fso = CreateObject("Scripting.FileSystemObject")

'Getting the Folder Object
Set ObjFolder = fso.GetFolder("C:\Users\Susan\Desktop\Anime\ova")

'Creating an Output File to write the File Names
Set ObjOutFile = fso.CreateTextFile("C:\Users\Susan\Documents\iMacros\Macros\WindowsFiles.txt")

'Getting the list of Files
Set ObjFiles = ObjFolder.Files

'Writing Name and Path of each File to Output File
For Each ObjFile In ObjFiles
    ObjOutFile.WriteLine(ObjFile.Path)
Next

ObjOutFile.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top