Download Article
Download Article
Quick tutorial on using 7-Zip to create compressed folders
This wikiHow article will show you how to use the free software 7-Zip to create multiple compressed folders in one go. This may come in handy for times when you are backing up your computer files or for whenever you need to compress a lot of file folders in general. This method involves using 7-Zip in a Windows batch file.
Steps
-
Install 7-Zip. If you let it install using the default settings, it should typically be in "C:\Program Files\7-zip\7z.exe."
- For this tutorial, let's say that you have some folders from your music collection that you want to compress so you can back them up on an external hard drive. These folders are contained inside a 'larger' folder named 'My Music.'
-
Open the Notepad app. You won't need to use 7-Zip's graphical user interface, so no need to run it after installing.Advertisement
-
In Notepad, insert this single line of code:
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
-
Note: If you'd like to output to .ZIP files, change the "
%%X.7z
" to "%%X.zip
" -
Click 'File' then 'Save As'.
-
Browse to the location of the folders you want to compress. In our example it is in C:\My Music.
-
Create your very own batch file by setting 'Save as type' to 'All files' and naming it something like 'foldertomultiple7z.bat'. Take note of the file extension, which is .bat. Be sure not to set the file type as 'Text Documents' too.
-
Click Save.
-
Close Notepad and navigate to your 'My Music' folder. Notice that the batch file is at the same directory level as the folders that need to be compressed.
-
Run the batch file by double-clicking on your bat file within your 'My Music' folder. DO NOT run as Administrator (option appears in right-click menu) - running as Administrator will compress the files in windows/system32. After you double-click on the bat file, the windows command prompt appears and 7-Zip begins to do its thing.
- The windows command prompt disappears when all compressed folders are created. You should now see them inside your folder.
-
Verify the validity of your compressed folders. To do this, highlight them all and click the right mouse button. If you installed 7-Zip in its default setting, you'll have its menu incorporated in the Windows shell. Navigate to it and click 'Test Archive.'
- 7-Zip should report that there are no errors in your archive.
- You are done creating multiple compressed folders in one go using 7-Zip. You can now move them to the external hard drive. You can delete the batch file you created or move it to a different folder.
Advertisement
Community Q&A
Search
-
QuestionHow can I zip only certain file types (e.g. PDF) across multiple folders/sub-folders?Community AnswerCreate a bat file with the following command (replace pdf with desired extension): FOR %%i IN (*.pdf*) DO "c:\Program Files\7-Zip\7z.exe" a "%%~ni.zip" "%%i".
-
QuestionWhat if the folder names have spaces?Community AnswerSpaces in the folder names did not cause any issues for me. Test it out on a few practice folders and you should be able to tell if there are any issues.
-
QuestionCan a bunch of files be password-protected using a batch file?Community AnswerYes; after the command, add the -p switch and then the password with no spaces between (i.e. "-ppassword"). Add -mhe on the end of that to encrypt the headers, which that means that whoever opens the zipped archive will have to provide a password to view its contents.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
- Changing the code in Notepad so that the resulting file extension is .cbz (instead of .zip) will enable this to work well for people using this batch file to show up in comic book readers.Thanks
- Keep your batch file for future use. The next time you need to compress multiple folders just Copy/Paste it to the main directory where the said folders reside and run it.Thanks
- DO NOT run as administrator. This will compress the files in windows/system32. Just double-clicking from within the target folder will do the job.Thanks
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement
Things You'll Need
- A computer with the Windows operating system.
- 7-Zip, which you can download from here .
- A text editor for creating the batch file, Windows Notepad is enough.
About This Article
Thanks to all authors for creating a page that has been read 352,189 times.
Advertisement