How to give variable folder path?

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Ruriko
Posts: 1
Joined: Fri Aug 17, 2012 6:10 pm

How to give variable folder path?

Post by Ruriko » Fri Aug 17, 2012 6:12 pm

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: Select all

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:UsersSusanDesktopAnimeova")

'Creating an Output File to write the File Names
Set ObjOutFile = fso.CreateTextFile("C:UsersSusanDocumentsiMacrosMacrosWindowsFiles.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 

Locked