First, make sure that the 7zip directory is in your path. Usually, it is located at
C:\Program Files\7-Zip
Next, write the following in batch file
Zip all files in a directory
for /f %%A in ('dir /b') do 7z a -tbzip2 "%%A.bz2" "%%A"
Zip files with a specific extension in a directory (download batch file)
for /f %%A in ('dir /b *.txt *.dat') do 7z a -tbzip2 "%%A.bz2" "%%A"
Save and run in the directory where you want to zip the files.
Here, I am compressing using bzip2 (notice the switch: –tbzip2). You can change that to
-tzip for zip
-tgz for gz
-t7z for 7z
some more examples here.
Cite as:
Saad, T. "7zip Batch Zip." Weblog entry from
Please Make A Note.
http://pleasemakeanote.blogspot.com/2009/05/7zip-batch-zip.html


0 comments:
Post a Comment