romeotheriault Posted February 27, 2006 Share Posted February 27, 2006 I'm have a loop setup that runs every 3 seconds scanning a directory for batch files. I need it to be able to run any number of batch files that it finds in the directory. If I tell it the filename it works fine but in real life these batch files will have different names. The only thing they will have in common is that they are batch files and the beginning of the file name will be the same. Is there anyway I can use a wildcard to do this? I've tried but can't seem to get it to work. Thank you for any help. Romeo Link to comment Share on other sites More sharing options...
Stumpii Posted February 27, 2006 Share Posted February 27, 2006 Try modifying the following, from the help file:; Shows the filenames of all files in the current directory.$search = FileFindFirstFile("*.*") ; Check if the search was successfulIf $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") ExitEndIfWhile 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file)WEnd; Close the search handleFileClose($search)If you still have no luck, post your code so far. Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity. Link to comment Share on other sites More sharing options...
ChrisL Posted February 27, 2006 Share Posted February 27, 2006 Something like... While 1 $search = FileFindFirstFile("*.*") If $search = -1 Then Sleep (3000) EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight ($file,3) = "bat" then run($file) WEnd ; Close the search handle FileClose($search) Sleep (3000) Wend [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
romeotheriault Posted February 27, 2006 Author Share Posted February 27, 2006 Thanks alot guys. This worked charms. I was busy working on it and was so close. I was missing the if @error then exitloop line. Thanks again. Romeo Something like... While 1 $search = FileFindFirstFile("*.*") If $search = -1 Then Sleep (3000) EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If StringRight ($file,3) = "bat" then run($file) WEnd ; Close the search handle FileClose($search) Sleep (3000) Wend Link to comment Share on other sites More sharing options...
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