Home » Questions » Computers [ Ask a new question ]

How to make 7-zip do a whole bunch of folders

How to make 7-zip do a whole bunch of folders

I got a bunch of pictures that I had to crop into 800x600 pixels. That was easily done, but now I have to upload them so the family can see them all.

Asked by: Guest | Views: 388
Total answers/comments: 5
bert [Entry]

"Run from a command prompt whose working directory is your My Pictures directory, this command will create a zip file of the contents of each subdirectory, leaving all of the zip files in your My Pictures directory.

Edit: I have added the quotation marks necessary to allow for directories with spaces in their names.

for /D %%d in (*.*) do 7z a -tzip ""%%d.zip"" ""%%d""

Also: The following version will not put files in a subdirectory inside of the zip file, but instead in its root:

for /D %%d in (*.*) do 7z a -tzip ""%%d.zip"" "".\%%d\*""

In Windows 7 and above

for /D %d in (*.*) do 7z a -tzip ""%d.zip"" ""%d""

or

for /D %d in (*.*) do 7z a -tzip ""%d.zip"" "".\%d\*"""
bert [Entry]

"Just a slight update of eleven81's answer: The code below creates a batch file which multiple items can be dropped onto.

@echo off
if [%1]==[] goto :eof
:loop
7z a -tzip ""%~1.zip"" ""%~1""
shift
if not [%1]==[] goto loop

This batch file can then be added to the context menu via the registry:

create a new key under [HKEY_CLASSES_ROOT\Folder\shell], call it cmd1
Edit the string value and call it 'Batch Zip'
create another new key under this one and call it command
Change the value of this to your path, with double escaped slashes

So for example, my entry is
""C:\Users\Rory\Dropbox\_apps\batch_zip.bat"" ""%1""

Once you do this you'll have an entry in your context menu for 'Batch Zip' which will batch zip any selected folders into separate archives

However, if you do this via the context menu, it will unfortunately run all operations simultaneously, and as anyone who's done a lot of zipping and unzipping will know, zipping folders works a lot faster one after the other than all at once.

If anyone knows a way to fix this in the registry please do tell.

Dragging the selected folders onto the batch will do them one after the other."
bert [Entry]

"7-zip has an option to UNZIP every file into its own folder (*/), but lacks the context commands to do the opposite action you are looking for.

That said, I remember doing this exact thing using winrar in the past. There's an option ""unique archive per folder"" or something to that effect."
"7-zip has an option to UNZIP every file into its own folder (*/), but lacks the context commands to do the opposite action you are looking for.

That said, I remember doing this exact thing using winrar in the past. There's an option ""unique archive per folder"" or something to that effect."
bert [Entry]

"Here's how I got it to work:

for /D %d in (*.*) do ""C:\Program Files\7-Zip\7z.exe"" a -tzip ""%d.zip"" "".\%d\*"""
bert [Entry]

Get picasa and upload to picasa's web album. Then everyone can easily get the photos online and view them.Might be even able to upload the originals (so your family can print the larger versions)