Eighty Posted July 19, 2006 Share Posted July 19, 2006 I need to find a script that can create an array of file names in a directory. Say i have three files named Bob1.exe, Bob2.mp3, Bob3.txt. located in C:\CoolFolder\ I want to be able to Give my script a path "C:\CoolFolder\" and be able to grab all of the file names in that folder. I cant seem to be able to figure out how to list file names in an array for the life of me. Can it be done? Thanks a ton, Eighty Link to comment Share on other sites More sharing options...
BPBNA Posted July 19, 2006 Share Posted July 19, 2006 Check the help file for FileFindFirstFile() and FileFindNextFile(). It has a good example: ; Shows the filenames of all files in the current directory, note that "." and ".." are returned. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search) Link to comment Share on other sites More sharing options...
Eighty Posted July 19, 2006 Author Share Posted July 19, 2006 (edited) I always use the help file as a referance, I have been at this for a few hours now.. thanks a ton. Edit: Wow i must have missed that 1 haha wtf is wrong with me.. thx again Edited July 19, 2006 by Eighty Link to comment Share on other sites More sharing options...
Skruge Posted July 19, 2006 Share Posted July 19, 2006 I need to find a script that can create an array of file names in a directory. Say i have three files named Bob1.exe, Bob2.mp3, Bob3.txt. located in C:\CoolFolder\I want to be able to Give my script a path "C:\CoolFolder\" and be able to grab all of the file names in that folder.I cant seem to be able to figure out how to list file names in an array for the life of me. Can it be done?Thanks a ton, Eighty Welcome to the forums!If you want to pass the path as a commandline parameter, look up $CMDLine in the help file.FileSelectFolder would be a GUI method.Also, check out _FileListToArray. (beta) [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now