Batch + regex + 7-zip
Posted on 2015-01-23
I am currently working on a batch script to compress files with 7-zip but I am having some difficulty with regular expressions.
I would like to compress any log file that ends with digits 0 to 365.
Here is my batch file :
IF EXIST C:\data\test.log.* (
"C:\Program Files\7-Zip\7z.exe" a -tzip "C:\data\archives\test.zip" "C:\data\test.log.*" -mm=lzma -mx9
) ELSE (
The problem is that even if there is no log file, the batch file will still create an empty zip file in C:\data\archives
I tried several things like test.log.* test.log.??? test.log.[0-3][0-9][0-9] but nothing works.
To summarize, I just want compress existing log file that ends with digits 0 to 365 in C:\data. If there is no log file the batch file exit.