Jump to content

files in the current directory


Guest Timo
 Share

Recommended Posts

Hello together,

the following code shows me each file in a messagebox:

; Shows the filenames of all files in the current directory

$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)

How can I get all the files in one list? Has anyone an idea?

Thanks,

Timo

Link to comment
Share on other sites

Do it in a dos bat like this :

dir/s/oe %1 /o:gn > "%temp%\Dir Listing"
cd\
if not exist dirlist\NUL md dirlist
if exist c:\dirlist\Dirlist.txt goto Two
move "%temp%\Dir Listing" c:\dirlist\Dirlist.txt
goto End
:Two
move "%temp%\Dir Listing" c:\dirlist\Dirlist2.txt
:End
cd dirlist
call nextfile Dirlist txt
cd\
c:\dirlist\%Highest%

maybe that will help you .

Link to comment
Share on other sites

@Timo: you could add all 'find files' to an array like this:

$dirlist[1000]; ok..I know that ~1000 files in one directory is not really real;-)
$search = FileFindFirstFile("*.*") 

; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
Exit
EndIf

$idx = 0; this variable you could use to set the highest array-entry
While 1
$file = FileFindNextFile($search) 
If @error Then ExitLoop
$idx = $idx + 1
$dirlist[0] = $idx; save the current (max) index to the first array-field
$dirlist[$idx] = $file; save the $file in the current array-field which ist pointed by the current index
MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)
Link to comment
Share on other sites

Hi,

thanks a lot. I´m new to AutoIt and this is my first program. I think I take Larrys solution it is the most simple for me.

By the way, please excuse my bad english but I come from Germany... :D

I´m very surprised how fast your reaction was. It seems to be a very good board and nice people helping everyone, isn´t it?

Now I go programming.

Bye,

Timo

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...