How to Use 7Zip to Create Multiple Compressed Folders in One Go

Опубликовал Admin
16-06-2021, 02:40
741
0
This article will show you how to use the free software 7zip 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 7zip in a Windows batch file. For this tutorial, let's say that you have a 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.'

Steps

  1. Install 7zip. If you let it install in its default setting it should typically be in "C:\Program Files\7-zip\7z.exe."
  2. Fire up Notepad. You won't need to use 7zip's graphical user interface, so no need to run it after installing.
  3. In Notepad, insert this single line of code: for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
  4. Note: If you'd like to output to .ZIP files, change the "%%X.7z" to "%%X.zip"
  5. Click 'File' then 'Save As'.
  6. Browse to the location of the folders you want to compress. In our example it is in C:\My Music.
  7. 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.
  8. Click Save.
  9. 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.
  10. 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 7zip begins to do its thing.
    • The windows command prompt disappears when all compressed folders are created. You should now see them inside your folder.
  11. Verify the validity of your compressed folders. To do this, highlight them all and click the right mouse button. If you installed 7zip in its default setting, you'll have its menu incorporated in the Windows shell. Navigate to it and click 'Test Archive.'
    • 7zip should report that there are no errors in your archive.
    • You are done creating multiple compressed folders in one go using 7zip. 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.

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.
  • 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.
  • DO NOT run as administrator. This will compress the files in windows/system32. Just double-click from within target folder will do the job.
  • If 7-zip is installed somewhere else in your system, find its location and replace it in the code.
  • You can use the batch file to compress any folder, not just music folders.
  • You can name the .bat file to friendly name like 7z-all.bat and put it inside Windows folder, so it will be accessible for the whole system. After that to use, In Windows 7 and 8.x, click with the right mouse button in the blank space of a folder holding the Shift key, an option Open Command Window Here will appear. Clicking that will open a command line window for the current folder. Then just type the 7z-all (no need for the .bat extension) and it will start to compress all the folders inside that one.

Things You'll Need

  • A computer with the Windows operating system.
  • 7zip, which you can download from here.
  • A text editor for creating the batch file, Windows Notepad is enough.
Теги:
Information
Users of Guests are not allowed to comment this publication.