kalayaan Posted March 10, 2004 Posted March 10, 2004 hi, i may be missing something but can FileFIndFirstfile search subdirectories?. i read through the help file but i didn't find any mention of it. appreciate your help. kala
trids Posted March 10, 2004 Posted March 10, 2004 You might want to try parsing the results of the DOS Dir command, which you can switch to search recursively... RunWait(@Comspec & " /c Dir C:\Winnt\Temp /s/b > C:\_ParseThis.TXT", "", @SW_HIDE)Of course, you can also tune it to look for file masks (*.XLS, say), or to discriminate between files and folders. At the DOS prompt say Dir /? for inspiration
kalayaan Posted March 31, 2004 Author Posted March 31, 2004 (edited) Just a follow-up. Is there a way to pass the result of the dir command directly into a variable or an array instead of into a temporary text file? Like: $A = RunWait(@Comspec & " /c Dir MyFile.doc /s/b", "", @SW_HIDE) But that didn't work though. It only passed the exit code of the dos command (0 if not found, 1 if found) Thanks alot. Edited March 31, 2004 by kalayaan
redndahead Posted March 31, 2004 Posted March 31, 2004 Nope but you can use a combination of exporting the results to a text file and then using the UDF _FileReadToArray() that comes with AutoITV3. red
ezzetabi Posted March 31, 2004 Posted March 31, 2004 (edited) Easy as cake.... Run(@comspec &" /c dir "& $FOLDER & "\" & $WILDCARDS &" /b/s >"& @TempDir &"\list.tmp") And parse the file @temp\list.tmp with a FileReadLine loop. EDIT: OPS... I didnt saw that the answer were already there... EZZETABI :iamstupid: Edited March 31, 2004 by ezzetabi
kalayaan Posted March 31, 2004 Author Posted March 31, 2004 Not to worry ezzetabi Thanks guys for your kind responses. I guess, it's either I use a long code (I found some all over the forum) using all AutoIt functions to go into subdirectories or use dos with a temporary text file. I'm thinking that parsing the text file is more simple (is it?) and anyways, I can delete the file afterwards. (I'd appreciate more tips, though) BTW, what I was trying to do was for the code to look into several directories (some with subdirs) that I use to store my unsorted downloads from the internet and move any file found into another drive at the end of the day. Thanks a lot.
scriptkitty Posted March 31, 2004 Posted March 31, 2004 (edited) The list into an array can be done in a line or two. I took a few more to display it out for ya. I personally like to hide the dos window, and using runwait on the dos box keeps you with the correct data ( AutoIt might process the file before Dos is done making the file.) I also replace @LF so I have a cleaner array (do to the way I read it in.) $folder="C:\Documents and Settings\scriptkitty\My Documents" $wildcards="*.*" Runwait(@comspec &' /c dir "'& $FOLDER & '\' & $WILDCARDS &'" /b/s >'& @TempDir &'\list.tmp',"",@SW_HIDE) $lines=StringSplit(Stringreplace(fileread(@TempDir & "\list.tmp",FileGetSize (@TempDir &"\list.tmp")),@lf,""),@CR) $alllines="" for $i=1 to $lines[0]-1 $alllines=$alllines& @crlf &"File"&$i & " = "&$lines[$i] next msgbox(1,$lines[0],$alllines) edit.. I would also use ' and add the " so that you can use long filenames in your searches, Dos is kinda perticular sometimes. Edited March 31, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
ezzetabi Posted March 31, 2004 Posted March 31, 2004 (edited) RunWait is usually better as ScriptKiddy said, but I can give an other advice... If the operation are long like in big folders you can put a ToolTip... Like ToolTip("Searching....",@desktopheight /3,0); A often unused part of the screen RunWait(@comspec &" /c dir "& $FOLDER & "\" & $WILDCARDS &" /b/s >"& @TempDir &"\list.tmp") ToolTip("") Edited March 31, 2004 by ezzetabi
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