It is always advisable to read the documentation of the commands to use before creating a batch file.
- xcopy (Microsoft Windows XP documenation, easier to read) or xcopy (Microsoft TechNet article)
- Documentation for 7-Zip standalone command line tool
7za
is installed together with 7-Zip in program files folder of 7-Zip. The file to view is 7-zip.chm
, a Windows help file.
The switches /s
and /e
belong to command xcopy
, but are appended to call of 7za
. /s
is for copying also subdirectories, but not empty subdirectories. /e
is for copying also subdirectories including empty subdirectories. It is possible to specify both, but usually just /e
needs to be specified to copy a directory tree completely using xcopy
.
To recursively archive all files and folders of a folder with 7za
the switch -r
must be used according to 7-Zip documentation.
@echo off
%SystemRoot%\System32\xcopy.exe "\\READYSHARE\USB_Storage\Address Book\Address Book" "%USERPROFILE%\Desktop\Zip" /E /I
"%ProgramFiles%\7-Zip\7za.exe" a –tzip "%USERPROFILE%\Desktop\Zipped.zip" -r "%USERPROFILE%\Desktop\Zip"
pause
I have not executed this batch file, but it should work if path to 7za.exe
is correct on your computer.