Oct 11, 2002 #1 richf6 Programmer Mar 1, 2002 6 0 0 US I need to list all the files in a folder. I need file name and extension. Would appreciate any help. :-D
I need to list all the files in a folder. I need file name and extension. Would appreciate any help. :-D
Oct 11, 2002 #2 mapman04 IS-IT--Management Mar 28, 2002 158 0 0 US Here's a script that will write the file name and extension to a text file. ========================== Dim fso,fol,fil,strTitle,flB,cf1,fn1,flC,flD,flE,flF,flG,flH,oShell,flA Set fso = Wscript.CreateObject("Scripting.FileSystemObject" Set oShell = WScript.CreateObject ("WSCript.shell" strTitle = "File Listing" Set fol = fso.GetFolder("F:\Data" Set fil = fol.Files Set cf1 = fso.CreateTextFile("F:\Data\FileList.txt",True) cf1.WriteLine(strTitle) cf1.Writeline(Now()) cf1.WriteLine(" " fn1 = 1 For Each flA in fil cf1.WriteLine("File No. " & fn1 & " " & flA.Name) fn1 = fn1 + 1 Next cf1.WriteLine("Process finished at: " & Time()) cf1.WriteLine(" " cf1.Writeline(Now()) cf1.Close oShell.Popup "Process Complete", 6, strTitle, vbInformation WScript.quit Upvote 0 Downvote
Here's a script that will write the file name and extension to a text file. ========================== Dim fso,fol,fil,strTitle,flB,cf1,fn1,flC,flD,flE,flF,flG,flH,oShell,flA Set fso = Wscript.CreateObject("Scripting.FileSystemObject" Set oShell = WScript.CreateObject ("WSCript.shell" strTitle = "File Listing" Set fol = fso.GetFolder("F:\Data" Set fil = fol.Files Set cf1 = fso.CreateTextFile("F:\Data\FileList.txt",True) cf1.WriteLine(strTitle) cf1.Writeline(Now()) cf1.WriteLine(" " fn1 = 1 For Each flA in fil cf1.WriteLine("File No. " & fn1 & " " & flA.Name) fn1 = fn1 + 1 Next cf1.WriteLine("Process finished at: " & Time()) cf1.WriteLine(" " cf1.Writeline(Now()) cf1.Close oShell.Popup "Process Complete", 6, strTitle, vbInformation WScript.quit