How to make 7-zip do a whole bunch of folders
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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.
Thing is, this is 500MB in pictures. I decided to simply zip the separate folders, which each contain an almost equal amount of pictures. This way I can upload a couple each day. Doing this manually is a very long and hard job. I wonder if there is a way to make 7-zip handle each folder individually?
I think I'll need a batch file to do it, but I'm not good with that.
I've put everything under one folder. In the various subfolders is where the pictures are located. What I need is for the contents of that folder to be zipped. I'm not sure if I can just zip the folder along with it. I know PHP has a zip module, I've just never worked with it, so I'm not sure whether it can handle the fact that the content of the zip is a folder which contains the items, instead of just the items.
batch 7-zip
add a comment |
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.
Thing is, this is 500MB in pictures. I decided to simply zip the separate folders, which each contain an almost equal amount of pictures. This way I can upload a couple each day. Doing this manually is a very long and hard job. I wonder if there is a way to make 7-zip handle each folder individually?
I think I'll need a batch file to do it, but I'm not good with that.
I've put everything under one folder. In the various subfolders is where the pictures are located. What I need is for the contents of that folder to be zipped. I'm not sure if I can just zip the folder along with it. I know PHP has a zip module, I've just never worked with it, so I'm not sure whether it can handle the fact that the content of the zip is a folder which contains the items, instead of just the items.
batch 7-zip
1
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
105 folder total
– KdgDev
Jan 11 '10 at 20:06
add a comment |
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.
Thing is, this is 500MB in pictures. I decided to simply zip the separate folders, which each contain an almost equal amount of pictures. This way I can upload a couple each day. Doing this manually is a very long and hard job. I wonder if there is a way to make 7-zip handle each folder individually?
I think I'll need a batch file to do it, but I'm not good with that.
I've put everything under one folder. In the various subfolders is where the pictures are located. What I need is for the contents of that folder to be zipped. I'm not sure if I can just zip the folder along with it. I know PHP has a zip module, I've just never worked with it, so I'm not sure whether it can handle the fact that the content of the zip is a folder which contains the items, instead of just the items.
batch 7-zip
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.
Thing is, this is 500MB in pictures. I decided to simply zip the separate folders, which each contain an almost equal amount of pictures. This way I can upload a couple each day. Doing this manually is a very long and hard job. I wonder if there is a way to make 7-zip handle each folder individually?
I think I'll need a batch file to do it, but I'm not good with that.
I've put everything under one folder. In the various subfolders is where the pictures are located. What I need is for the contents of that folder to be zipped. I'm not sure if I can just zip the folder along with it. I know PHP has a zip module, I've just never worked with it, so I'm not sure whether it can handle the fact that the content of the zip is a folder which contains the items, instead of just the items.
batch 7-zip
batch 7-zip
edited May 14 '12 at 10:24
akira
49.6k15113152
49.6k15113152
asked Jan 11 '10 at 16:16
KdgDevKdgDev
2,368154364
2,368154364
1
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
105 folder total
– KdgDev
Jan 11 '10 at 20:06
add a comment |
1
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
105 folder total
– KdgDev
Jan 11 '10 at 20:06
1
1
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
105 folder total
– KdgDev
Jan 11 '10 at 20:06
105 folder total
– KdgDev
Jan 11 '10 at 20:06
add a comment |
7 Answers
7
active
oldest
votes
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*"
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
Theclasspath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with thepath
where the shell looks for executables.
– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
This worked great for me, although I had to change%%d
to%d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.
– Benjam
Sep 8 '11 at 21:38
|
show 1 more comment
I couldn't get the command line to work, instead I downloaded WinRAR and mtone was right - WinRAR does have an option to zip multiple folders into their own separate ZIP files.
E.g. C:FilesFables 01
into C:FilesFables 01.zip
, and C:FilesFables 02
into C:FilesFables 02.zip
.
With WinRAR, open the Folder that contains the folders you want to zip, then follow these steps:
- Select all folders you want zipped/rared
- Click "ADD" or Alt+A or Commands -> "Add files to Archive"
- Select RAR or ZIP
- go to "Files" tab
- Check "Put each file to separate archive" under the Archives box
When you've got any other settings you like fixed, hit OK and boom: multiple ZIP files of multiple folders. This worked so much easier than command line 7zip.
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
add a comment |
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_ROOTFoldershell], 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:UsersRoryDropbox_appsbatch_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.
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
add a comment |
Tip: if you're images are JPGs, they are already compressed. use 7-Zip in 'archive' mode without compression (compression level: store) this will speed up the process tremendously.
even if you use Ultra compression you will hardly gain 5%, certainly not worth the effort.
I was thinking in terms of practically
adding attachments.
i wouldn't send them as email attachment. rather upload the to a so called one-click-hosting server (e.g. drop.io, rs, mu, ms, etc., choices are plenty) and then send the download link via email to your friends and family.
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
|
show 4 more comments
I found roryok's answer to be very helpful, he provided a batch script
for Windows
that allows you to drag-&-drop
files for quick, automated archiving.
To use this script, just save it with a .bat
extension, and then you can drag-&-drop files and/or folders onto the batch file ( or a shortcut to the batch file ).
.zip
files will be created in the same directory as the source files.
( although the destination can be altered in the script @ archivePath
)
Some updates I made to improve ease of customization & overall functionality:
- added named variables
- implemented a
for
loop that iterates through the given arguments
( along withdelayedexpansion
to allow runtime variables ) - added
if
conditions to differentiatefiles
&folders
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
( EG:archive.zipfile.txt
VSarchive.zipparent_folderfile.txt
)
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
- added an error log to display failed instances or display a success message if there were no errors
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set sevenZip="C:Program Files7-Zip7z.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Archived
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder, & Archive Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x*"
Set archivePath="%%~x.zip"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide 7-Zip Output
echo !newLine!!newLine!!separator!!newLine!!newLine!
Rem // Add Files To Zip Archive
!sevenZip! A -TZIP !archivePath! !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause
add a comment |
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.
add a comment |
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)
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f94421%2fhow-to-make-7-zip-do-a-whole-bunch-of-folders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
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*"
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
Theclasspath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with thepath
where the shell looks for executables.
– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
This worked great for me, although I had to change%%d
to%d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.
– Benjam
Sep 8 '11 at 21:38
|
show 1 more comment
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*"
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
Theclasspath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with thepath
where the shell looks for executables.
– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
This worked great for me, although I had to change%%d
to%d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.
– Benjam
Sep 8 '11 at 21:38
|
show 1 more comment
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*"
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*"
edited Sep 21 '13 at 19:32
user256245
32
32
answered Jan 11 '10 at 16:49
eleven81eleven81
7,568124677
7,568124677
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
Theclasspath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with thepath
where the shell looks for executables.
– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
This worked great for me, although I had to change%%d
to%d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.
– Benjam
Sep 8 '11 at 21:38
|
show 1 more comment
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
Theclasspath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with thepath
where the shell looks for executables.
– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
This worked great for me, although I had to change%%d
to%d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.
– Benjam
Sep 8 '11 at 21:38
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
I've tried adding the 7-zip folder to my classpath, but it won't work. If I use the entire string to locate the executable instead of just 7z, it does work. I though that adding that string to the class path should have the same effect?
– KdgDev
Jan 11 '10 at 20:40
The
classpath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with the path
where the shell looks for executables.– eleven81
Jan 12 '10 at 13:13
The
classpath
is where Java looks for classes and libraries. google.com/search?q=classpath You've apparently confused that with the path
where the shell looks for executables.– eleven81
Jan 12 '10 at 13:13
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Question: the script works, but not when there are spaces in the folder-name...
– KdgDev
Jan 29 '10 at 17:06
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
Thanks for the update. With the second script, do you mean that the contents of the zip will be "flattened"?
– KdgDev
Jan 29 '10 at 22:10
6
6
This worked great for me, although I had to change
%%d
to %d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.– Benjam
Sep 8 '11 at 21:38
This worked great for me, although I had to change
%%d
to %d
as my Win 7 box complained about the var name being too long throwing a "%%d was unexpected at this time" error.– Benjam
Sep 8 '11 at 21:38
|
show 1 more comment
I couldn't get the command line to work, instead I downloaded WinRAR and mtone was right - WinRAR does have an option to zip multiple folders into their own separate ZIP files.
E.g. C:FilesFables 01
into C:FilesFables 01.zip
, and C:FilesFables 02
into C:FilesFables 02.zip
.
With WinRAR, open the Folder that contains the folders you want to zip, then follow these steps:
- Select all folders you want zipped/rared
- Click "ADD" or Alt+A or Commands -> "Add files to Archive"
- Select RAR or ZIP
- go to "Files" tab
- Check "Put each file to separate archive" under the Archives box
When you've got any other settings you like fixed, hit OK and boom: multiple ZIP files of multiple folders. This worked so much easier than command line 7zip.
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
add a comment |
I couldn't get the command line to work, instead I downloaded WinRAR and mtone was right - WinRAR does have an option to zip multiple folders into their own separate ZIP files.
E.g. C:FilesFables 01
into C:FilesFables 01.zip
, and C:FilesFables 02
into C:FilesFables 02.zip
.
With WinRAR, open the Folder that contains the folders you want to zip, then follow these steps:
- Select all folders you want zipped/rared
- Click "ADD" or Alt+A or Commands -> "Add files to Archive"
- Select RAR or ZIP
- go to "Files" tab
- Check "Put each file to separate archive" under the Archives box
When you've got any other settings you like fixed, hit OK and boom: multiple ZIP files of multiple folders. This worked so much easier than command line 7zip.
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
add a comment |
I couldn't get the command line to work, instead I downloaded WinRAR and mtone was right - WinRAR does have an option to zip multiple folders into their own separate ZIP files.
E.g. C:FilesFables 01
into C:FilesFables 01.zip
, and C:FilesFables 02
into C:FilesFables 02.zip
.
With WinRAR, open the Folder that contains the folders you want to zip, then follow these steps:
- Select all folders you want zipped/rared
- Click "ADD" or Alt+A or Commands -> "Add files to Archive"
- Select RAR or ZIP
- go to "Files" tab
- Check "Put each file to separate archive" under the Archives box
When you've got any other settings you like fixed, hit OK and boom: multiple ZIP files of multiple folders. This worked so much easier than command line 7zip.
I couldn't get the command line to work, instead I downloaded WinRAR and mtone was right - WinRAR does have an option to zip multiple folders into their own separate ZIP files.
E.g. C:FilesFables 01
into C:FilesFables 01.zip
, and C:FilesFables 02
into C:FilesFables 02.zip
.
With WinRAR, open the Folder that contains the folders you want to zip, then follow these steps:
- Select all folders you want zipped/rared
- Click "ADD" or Alt+A or Commands -> "Add files to Archive"
- Select RAR or ZIP
- go to "Files" tab
- Check "Put each file to separate archive" under the Archives box
When you've got any other settings you like fixed, hit OK and boom: multiple ZIP files of multiple folders. This worked so much easier than command line 7zip.
edited Mar 20 '17 at 10:17
Community♦
1
1
answered May 14 '12 at 9:45
user134042user134042
7111
7111
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
add a comment |
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
Even though it says "each file" this checkbox works with folders too.
– dhaupin
May 4 '16 at 16:47
1
1
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
Of all the proposed solutions here this one worked best for me in 2018. Just be sure to check that you want the archive to .zip or it will make a bunch of .rar files instead.
– Eric Hepperle - CodeSlayer2010
Nov 8 '18 at 20:42
add a comment |
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_ROOTFoldershell], 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:UsersRoryDropbox_appsbatch_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.
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
add a comment |
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_ROOTFoldershell], 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:UsersRoryDropbox_appsbatch_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.
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
add a comment |
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_ROOTFoldershell], 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:UsersRoryDropbox_appsbatch_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.
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_ROOTFoldershell], 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:UsersRoryDropbox_appsbatch_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.
edited Jun 21 '11 at 14:29
answered Jun 21 '11 at 14:17
roryokroryok
4971619
4971619
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
add a comment |
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
1
1
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
The 7z exe wasn't on my path and so I had to edit your script slightly. "C:Program Files (x86)7-Zip7z.exe" a -tzip "%~1.zip" "%~1"
– Ryan
Sep 4 '15 at 18:05
1
1
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
+1 for encouraging lazyness with drag & drop lol. I just posted a modified version @ http://superuser.com/a/1160047/678687
– Enteleform
Dec 25 '16 at 13:07
add a comment |
Tip: if you're images are JPGs, they are already compressed. use 7-Zip in 'archive' mode without compression (compression level: store) this will speed up the process tremendously.
even if you use Ultra compression you will hardly gain 5%, certainly not worth the effort.
I was thinking in terms of practically
adding attachments.
i wouldn't send them as email attachment. rather upload the to a so called one-click-hosting server (e.g. drop.io, rs, mu, ms, etc., choices are plenty) and then send the download link via email to your friends and family.
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
|
show 4 more comments
Tip: if you're images are JPGs, they are already compressed. use 7-Zip in 'archive' mode without compression (compression level: store) this will speed up the process tremendously.
even if you use Ultra compression you will hardly gain 5%, certainly not worth the effort.
I was thinking in terms of practically
adding attachments.
i wouldn't send them as email attachment. rather upload the to a so called one-click-hosting server (e.g. drop.io, rs, mu, ms, etc., choices are plenty) and then send the download link via email to your friends and family.
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
|
show 4 more comments
Tip: if you're images are JPGs, they are already compressed. use 7-Zip in 'archive' mode without compression (compression level: store) this will speed up the process tremendously.
even if you use Ultra compression you will hardly gain 5%, certainly not worth the effort.
I was thinking in terms of practically
adding attachments.
i wouldn't send them as email attachment. rather upload the to a so called one-click-hosting server (e.g. drop.io, rs, mu, ms, etc., choices are plenty) and then send the download link via email to your friends and family.
Tip: if you're images are JPGs, they are already compressed. use 7-Zip in 'archive' mode without compression (compression level: store) this will speed up the process tremendously.
even if you use Ultra compression you will hardly gain 5%, certainly not worth the effort.
I was thinking in terms of practically
adding attachments.
i wouldn't send them as email attachment. rather upload the to a so called one-click-hosting server (e.g. drop.io, rs, mu, ms, etc., choices are plenty) and then send the download link via email to your friends and family.
edited Jan 11 '10 at 18:25
answered Jan 11 '10 at 16:35
Molly7244
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
|
show 4 more comments
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
2
2
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
They will be easier to mail, though.
– Rook
Jan 11 '10 at 16:48
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
i don't think there's much difference in uploading 475 or 500 MB, certainly not enough to make up for the time it takes to compress a gazillion JPGs with 'Ultra' :)
– Molly7244
Jan 11 '10 at 17:10
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
I was thinking in terms of practically adding attachments. It's easier to add one file as attachment instead of 10. (when number of files grow, this becomes annoying).
– Rook
Jan 11 '10 at 17:50
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
Which is why Molly suggested "archive" mode; it stuffs 'em all into one file, without wasting time trying to compress something that's already compressed ...
– Adrien
Jan 11 '10 at 18:18
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
It's true I was reffering to her last sentence, but nevertheless, even with small reduction in size of jpeg files (and sometimes it's not so small, actually), it is still worth it. Time spend on compression is far less than time spend uploading it to let's say, gmail or some other mail (gmail having a relatively large attachment size allowance).
– Rook
Jan 11 '10 at 18:25
|
show 4 more comments
I found roryok's answer to be very helpful, he provided a batch script
for Windows
that allows you to drag-&-drop
files for quick, automated archiving.
To use this script, just save it with a .bat
extension, and then you can drag-&-drop files and/or folders onto the batch file ( or a shortcut to the batch file ).
.zip
files will be created in the same directory as the source files.
( although the destination can be altered in the script @ archivePath
)
Some updates I made to improve ease of customization & overall functionality:
- added named variables
- implemented a
for
loop that iterates through the given arguments
( along withdelayedexpansion
to allow runtime variables ) - added
if
conditions to differentiatefiles
&folders
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
( EG:archive.zipfile.txt
VSarchive.zipparent_folderfile.txt
)
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
- added an error log to display failed instances or display a success message if there were no errors
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set sevenZip="C:Program Files7-Zip7z.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Archived
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder, & Archive Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x*"
Set archivePath="%%~x.zip"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide 7-Zip Output
echo !newLine!!newLine!!separator!!newLine!!newLine!
Rem // Add Files To Zip Archive
!sevenZip! A -TZIP !archivePath! !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause
add a comment |
I found roryok's answer to be very helpful, he provided a batch script
for Windows
that allows you to drag-&-drop
files for quick, automated archiving.
To use this script, just save it with a .bat
extension, and then you can drag-&-drop files and/or folders onto the batch file ( or a shortcut to the batch file ).
.zip
files will be created in the same directory as the source files.
( although the destination can be altered in the script @ archivePath
)
Some updates I made to improve ease of customization & overall functionality:
- added named variables
- implemented a
for
loop that iterates through the given arguments
( along withdelayedexpansion
to allow runtime variables ) - added
if
conditions to differentiatefiles
&folders
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
( EG:archive.zipfile.txt
VSarchive.zipparent_folderfile.txt
)
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
- added an error log to display failed instances or display a success message if there were no errors
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set sevenZip="C:Program Files7-Zip7z.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Archived
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder, & Archive Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x*"
Set archivePath="%%~x.zip"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide 7-Zip Output
echo !newLine!!newLine!!separator!!newLine!!newLine!
Rem // Add Files To Zip Archive
!sevenZip! A -TZIP !archivePath! !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause
add a comment |
I found roryok's answer to be very helpful, he provided a batch script
for Windows
that allows you to drag-&-drop
files for quick, automated archiving.
To use this script, just save it with a .bat
extension, and then you can drag-&-drop files and/or folders onto the batch file ( or a shortcut to the batch file ).
.zip
files will be created in the same directory as the source files.
( although the destination can be altered in the script @ archivePath
)
Some updates I made to improve ease of customization & overall functionality:
- added named variables
- implemented a
for
loop that iterates through the given arguments
( along withdelayedexpansion
to allow runtime variables ) - added
if
conditions to differentiatefiles
&folders
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
( EG:archive.zipfile.txt
VSarchive.zipparent_folderfile.txt
)
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
- added an error log to display failed instances or display a success message if there were no errors
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set sevenZip="C:Program Files7-Zip7z.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Archived
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder, & Archive Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x*"
Set archivePath="%%~x.zip"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide 7-Zip Output
echo !newLine!!newLine!!separator!!newLine!!newLine!
Rem // Add Files To Zip Archive
!sevenZip! A -TZIP !archivePath! !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause
I found roryok's answer to be very helpful, he provided a batch script
for Windows
that allows you to drag-&-drop
files for quick, automated archiving.
To use this script, just save it with a .bat
extension, and then you can drag-&-drop files and/or folders onto the batch file ( or a shortcut to the batch file ).
.zip
files will be created in the same directory as the source files.
( although the destination can be altered in the script @ archivePath
)
Some updates I made to improve ease of customization & overall functionality:
- added named variables
- implemented a
for
loop that iterates through the given arguments
( along withdelayedexpansion
to allow runtime variables ) - added
if
conditions to differentiatefiles
&folders
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
( EG:archive.zipfile.txt
VSarchive.zipparent_folderfile.txt
)
- this allows folder contents to be added to the archive directly rather than enclosing the parent folder within the archive
- added an error log to display failed instances or display a success message if there were no errors
@Echo OFF
SetLocal EnableDelayedExpansion
Rem // 7-Zip Executable Path
Set sevenZip="C:Program Files7-Zip7z.exe"
Rem // START: NewLine Variable Hack
Set newLine=^
Rem // END: NewLine Variable Hack !! DO NOT DELETE 2 EMPTY LINES ABOVE !!
Rem // Set ErrorLog Variables
Set errorCount=0
Set separator=--------------------------------------------------------
Set errorLog=!newLine!!newLine!!separator!!newLine!!newLine!
Set errorPrefix=ERROR @:
Set successMessage=All Files Were Successfully Archived
Rem // Loop Through Each Argument
SetLocal DisableDelayedExpansion
for %%x in (%*) do (
Rem // Use Current Argument To set File, Folder, & Archive Paths
SetLocal DisableDelayedExpansion
Set filePath="%%~x"
Set directoryFiles="%%~x*"
Set archivePath="%%~x.zip"
SetLocal EnableDelayedExpansion
Rem // Source Is A Folder
if exist !directoryFiles! (
Set sourcePath=!directoryFiles!
)
Rem // Source Is A File
if not exist !directoryFiles! (
Set sourcePath=!filePath!
)
Rem // Print Separator To Divide 7-Zip Output
echo !newLine!!newLine!!separator!!newLine!!newLine!
Rem // Add Files To Zip Archive
!sevenZip! A -TZIP !archivePath! !sourcePath!
Rem // Log Errors
if ErrorLevel 1 (
Set /A errorCount=errorCount+1
Set errorLog=!errorLog!!newLine!!errorPrefix!!sourcePath!
)
)
Rem // Print ErrorLog
if !errorCount!==0 (
Set errorLog=!errorLog!!newLine!!successMessage!
)
Echo !errorLog!!newLine!!newLine!!newLine!
Rem // Keep Window Open To View ErrorLog
pause
edited Dec 25 '16 at 22:19
answered Dec 25 '16 at 13:03
EnteleformEnteleform
1215
1215
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
answered Jan 11 '10 at 16:28
mtonemtone
10.9k53759
10.9k53759
add a comment |
add a comment |
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)
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
add a comment |
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)
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
add a comment |
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)
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)
answered Jun 21 '11 at 14:35
KurruKurru
86841427
86841427
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
add a comment |
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
If you think people will be happy with downloading and extracting zip files I think you'll be sadly disappointed... Web interface is much easier for everyone involved....
– Kurru
Jun 22 '11 at 10:38
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f94421%2fhow-to-make-7-zip-do-a-whole-bunch-of-folders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
How many folders are you talking about? 7? 147? If you're not good with batch files, but maybe this is a good opportunity to tackle that challenge. :)
– JMD
Jan 11 '10 at 16:30
105 folder total
– KdgDev
Jan 11 '10 at 20:06