Jump to content

Cmdline Parsing For Wildcards


Recommended Posts

Hi folks!

Been working on a commandline parse utility, and want it to be able to handle wildcards, i.e.

program inputfiles.*

I need to (at least)

parse the cmdline[] var

find the files that match, using ? and * correctly

loop through each file performing operations in program

Code snippets / samples / suggestions on approach welcome.

I've got the code working for a specific file, but would like to have a generic executable that could

a) be used as a standalone utility and,

:whistle: be utilized as a piped or batched app.

I have viewed w/ interest the FileFindFirstFile / FileFindNextFile commands -- would

they be a recommended basis for what I am describing?

Thanks in advance!

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to post
Share on other sites
  • Developers

I have viewed w/ interest the FileFindFirstFile / FileFindNextFile commands -- would

they be a recommended basis for what I am describing?

FileFindFirstFile / FileFindNextFile should work fine and you can use the example in the helpfile.

When you require to also search the subdirectories you could use something like the below script.

; this does a DIR of the current and subdirectories... and sorts the filenames
runwait('cmd /c Dir "' & $CmdLine[1] & '" /s /b /x /ON  > files.txt',@scriptdir,@sw_hide)
$ifile = FileOpen("files.txt", 0)
; Check if file opened for reading OK
If $ifile = -1 Then
   MsgBox(0, "Error", "Unable to open: files.txt")
   Exit
EndIf
While 1
   $Fi_Rec = FileReadLine($iFile)
   If @error = -1 Then ExitLoop
  ; do what you want to do 
Wend
FileFindFirstFile
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

Thanks for the suggestion. Using FFFF/FFNF along w/ FileGetAttrib to process subdirs if necessary looks like it's going to work great! :whistle: AutoIT ROCKS!!!

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...