I had a similar problem and wanted to do it with a batch script. Here is how:
In the example below, the script looks for all .csv files starting with "cell_cfg" and "slave_cfg", collects them, and zips them in one file called 'cfg.7z' stored in a subdirectory called 'zip':
@ECHO OFF
setlocal enableDelayedExpansion
mkdir zip
ECHO collecting filenames...
set filenames="C:\Program Files\7-Zip\7z.exe" a -t7z "zip/cfg.7z
FOR %%i IN (cell_cfg*.csv) DO (
ECHO "%%i" | FIND /I "zip_cfg.bat" 1>NUL) || (
SET filenames=!filenames!" "%%i
)
)
FOR %%i IN (slave_cfg*.csv) DO (
ECHO "%%i" | FIND /I "zip_cfg.bat" 1>NUL) || (
SET filenames=!filenames!" "%%i
)
)
set filenames=%filenames%"
%filenames%
(Adjust the path of your 7z.exe and files/folder names. If you want .zip instead of .7z, rename the lines:
set filenames="C:\Program Files\7-Zip\7z.exe" a -t7z "zip/cfg.7z
into
set filenames="C:\Program Files\7-Zip\7z.exe" a -tzip "zip/cfg.zip
)
I saved it as 'zip_cfg.bat' and place it in the folder with the files I want to zip. Then I can call it in the command line: first, navigate to the folder with the files, then just call:
zip_cfg.bat
In case you want to zip all files in the folder ("*"), the 'FIND /I "zip_cfg.bat" 1>NUL' part stops the script from zipping the batch file itself.
Hope this helps someone... :)