I am trying to write a batch script that will run automatically compressing subdirectories using winrar or 7-zip:
Example:
My Pictures
Pics1 (Pics1.
Non of the provided solutions worked for me. I have created a script which packs first into 7z with maximum compression and then create rar archive for storage with recovery record (it also deletes the interim 7z archive):
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /R f:\ZA\SQL2005\ZA\ %%A IN (*.*) DO (
SET "file_without_suffix=%%~dpnA"
7z.exe a -t7z -m0=lzma2 -mx=9 -mfb=256 -md=1024m -ms=on "!file_without_suffix!.7z" "%%A"
REM -ep1 do not store path in archive
rar.exe a -m0 -rr -ep1 "!file_without_suffix!.rar" "!file_without_suffix!.7z"
DEL /Q /F "!file_without_suffix!.7z"
SET "file_without_suffix="
)
SETLOCAL DISABLEDELAYEDEXPANSION