I couldn't find details about how to use file mask in a batch file. My requirement,
forfiles -p "C:\what\ever" -s -m *.log -c "cmd /c somecommmand"
instead of selecting all the log files (*.log), how to select all the log files which has an integer suffix at the end. Eg, Among the following files,
test.log, test1.log, test2.log, test3.log..
I need a file mask to select all except test.log
I tried test*.log
, but that slects test.log as well. It is preferrable to not include the file name part (test). something like, *<0-9d>.log
.
thanks.
You could try the following, which I personally think is terrible, but it may just be what you need:
FOR %i IN (1 2 3 4 5 6 7 8 9 10 11 12 13 ...) DO IF EXIST test%i.log (somecommand)
If the suffix is really any integer number in a potentially very large range, this won't work — unless you nest several FOR
loops, where each takes care of only one digit, and you change the IF EXIST test%i.log
to something like IF EXIST test%a%b%c%d.log
(for four digits).
Also, there's no need to execute somecommand
in a separate shell (CMD /C
), unless of course that is in fact what you need to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With