Sign in to follow this  
Followers 0
Eighty

File Management

4 posts in this topic

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 :D

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Eighty

Share this post


Link to post
Share on other sites

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 :D

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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0