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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File List

Status
Not open for further replies.

richf6

Programmer
Joined
Mar 1, 2002
Messages
6
Location
US
I need to list all the files in a folder. I need file name and extension.

Would appreciate any help. :-D
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top