Currently I am working on a small utility which processes a specific archive format. The question is: suppose I have several files which either match *.zipped.*
pattern either not. The last asterisk is guaranteed to represent the format (extension). How do I pass all matching files to the utility via Windows .bat-file?
A sample script should be like that:
FOR /R "%CD%" %%I IN (*.zipped.*) DO (
SET file_name=%%I
offzip %%I !file_name:~end,end-7!%%~xI
)
where "offzip" represents the utility I use. Of course, this one does not help. By the way, extensions may be of different length.
Example cases:
- "sample.zipped.txt" -> "sample.txt"
- "zipped123.zipped.dat" -> "zipped123.dat"
- "abc.zipped.sampleextension" -> "abc.sampleextension"
Thank you for your help!
offzip "%%~I" "!file_name:.zipped.=."
...offzip "%%~I" "!file_name:.zipped.=.!"
%CD%
,/R
recurses the current working directory by default.FOR /R "%CD%" %%I IN (*.zipped.*) DO (SET file_name=%%I offzip "%%~I" "!file_name:.zipped.=.!")
... Now it saves the content to the file named "!file_name", with no extention... What am I doing wrong?( P.S. Cmd/bat do not seem to be that fast and that easy... Funny.