Sign in to follow this  
Followers 0
mortalic

Running files in a directory

8 posts in this topic

Hello all,

Still a noob, but I'm getting better!

So now I am trying to run through all the files in a diretory, here is what I am doing:

Dim $i_PID
Dim $search

$search = FileFindFirstFile("<pathtofile>\FI431*.exe")

if $search = -1 Then
    MsgBox(0,"Error", "No files found")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)

    if @error then ExitLoop
$i_PID = Run("<pathtofile>" & $file)
While ProcessExists($i_PID)
    sleep(100)
Wend

WEnd

the problem is, autoit doesn't do the same sorting as windows does, which causes the files to get evaluated out of order.

In windows the files sort correctly

Example:

file00001_019.exe

file00020_117.exe

file00118_148.exe

but autoit, using the filefindfirst code above reports them in this order:

file00020_117.exe

file00001_019.exe

file00118_148.exe

I'm not sure why it is doing that, it doesn't seem to make any sense, 019 is definatly lower than 117, but as you can see from the naming convention, it is denoting 1 through 19, 20 through 117, 118 through 148.

and like I said, windows displays it differently.

Any ideas?

Share this post


Link to post
Share on other sites



Look into helpfile at:

_FileListToArray()

_ArraySort()

ahh good call, dump it to an array, sort the array, then run it in order. Thanks! I'll pose if I get stuck.

Share this post


Link to post
Share on other sites

ok I'm stumped,

So I've narrowed my code down to this:

#Include <File.au3>
#Include <Array.au3>

$fileList=_FileListToArray("FI*.exe")

If @Error=1 Then
    MsgBox(0,"","No files found")
    Exit
EndIf
_ArrayDisplay($fileList,"File List")

But nothing happens when I run the script, no output, nothing. script, runs then exits. It's right out of the f1 help file, what am I doing wrong?

Share this post


Link to post
Share on other sites

ok I'm stumped,

So I've narrowed my code down to this:

#Include <File.au3>
#Include <Array.au3>

$fileList=_FileListToArray("FI*.exe")

If @Error=1 Then
    MsgBox(0,"","No files found")
    Exit
EndIf
_ArrayDisplay($fileList,"File List")

But nothing happens when I run the script, no output, nothing. script, runs then exits. It's right out of the f1 help file, what am I doing wrong?

Did you looked into helpfile at parametres for _FileListToArray ?!?

#Include <File.au3>
#Include <Array.au3>

$fileList=_FileListToArray("C:\some path\", "FI*.exe")

If @Error=1 Then
    MsgBox(0,"","No files found")
    Exit
EndIf
_ArrayDisplay($fileList,"File List")

Share this post


Link to post
Share on other sites

Did you looked into helpfile at parametres for _FileListToArray ?!?

#Include <File.au3>
#Include <Array.au3>

$fileList=_FileListToArray("C:\some path\", "FI*.exe")

If @Error=1 Then
    MsgBox(0,"","No files found")
    Exit
EndIf
_ArrayDisplay($fileList,"File List")
Well yeah... My code is practically verbatim from the help file... did I miss something?

Share this post


Link to post
Share on other sites

Missed a parameter in _FileListToArray...

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

Missed a parameter in _FileListToArray...

~cdkid

Ahh good call, I'll take a look at that.

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