7-Zipping multiple folders to separate/individual zip/archive files
So I thought I would write this solution up as I had already made a batch file to do this then promptly deleted it (subsequently Recuva couldn’t ‘recuva’ it, as I’d been throwing a lot of data on and off my PC and thus I assume it was over-written). The problem was I had several folders I wanted to zip into individual 7z archives. 7-zip lacks a ‘Add to “*.7z”‘ explorer context for multiple selected files or folders (even though it does include a ‘Extract to “*\”‘). Nor does this option appear within the application itself or via the command-line. I seem to recall this feature being available in the Explorer contexts for some ZIP program I once used (I think it was TUGzip), but I wanted to choose quite aggressive compression settings for the archives and I didn’t think this would be achievable except via the command-line.
So using a bit of Google skills I discovered the ‘for… in… do’ batch command. Which is quite powerful and I’m sure will come in handy again now that I know about it. For more information check out this guide: More Powerful Batch Files Part II – Iterating with “For”. Coupled with the 7-zip manual I arrived at a batch file with this line in it:
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\" -mx=9 -ms=on -md=26 -mfb=256
So copy that into a batch file, copy it to the directory where you have folders you want to zip to individual archives and run it. You might want to change (or just delete) the custom settings (e.g. the settings with -m at the end) as it set up to do some pretty heavy compression which does take quite a long time (but of course you can leave it running in the background without too much problem).