Sign in to follow this  
Followers 0
hcdebey

How can I produce a list of files in a directory?

5 posts in this topic

I want create a list of files in a directory with something like:

C:\>dir >filelist.txt

When I attempt this using ShellExecute I get a message that Windows can't find dir.

Any suggestions?

Share this post


Link to post
Share on other sites



I want create a list of files in a directory with something like:

C:\>dir >filelist.txt

When I attempt this using ShellExecute I get a message that Windows can't find dir.

Any suggestions?

There is no DIR.exe to run. The DIR command is "native to", or "embedded in" the command shell (i.e. CMD.exe). So for AutoIt to run an embedded command, you first run the shell:
Run(@ComSpec & " /c DIR C:\Temp1 > C:\Temp2.txt")

You can skip all that and get the list to an array with just _FileListToArray(). Check it out in the help file.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

If you wanted to do it that way..

Run(@ComSpec & " /c dir > file.txt")oÝ÷ Ø    趫Á¬²¢é¢pj{m¢ÚòËaÆ®¶­sb6æ6ÇVFRfÇC´fÆRæS2fwC°¢6æ6ÇVFRfÇC´'&æS2fwC° ¢b33c¶bÒôfÆTÆ7EFô'&gV÷C´3¢b3#µvæF÷w2gV÷C²ÂgV÷C²¢â¢gV÷C²Ã¥ô'&F7Æb33c¶b

Share this post


Link to post
Share on other sites

Thanks. Your suggestion is much better.

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