How to zip multiple folders in 7zip?
Solution 1
Running a basic batch compress job can be done thus. You will however need to edit the command as necessary to accommodate your specific requirements. This can be done through the use of various 'switches'; the syntax for doing so is available here.
Solution 2
This should work reasonably well:
find -maxdepth 1 -type d -exec p7zip {} \;
You should be able to construct your final command line from that easily.
-
-maxdepth 1
Only search 1 directory deep -
-type d
Only search for directories -
-exec p7zip {} \;
Pass every found item top7zip
- creating a.7z
archive of the folder.
Related videos on Youtube
pras92
Updated on September 18, 2022Comments
-
pras92 over 1 year
I have a folder, lets say,
MAIN
. Inside this folder, there are many folders(sayf1,f2,f2...
) which has subfolders and files in them. Now I need to zip these folders(f1,f2,f3...
) and their contents (which might be subfolders and files) into separate zips(f1.7z, f2.7z, f3.7z ...
) and put them underMAIN
folder.Also, I need to use these settings for all the zips. .7z, LZMA2, Ultra, 1024MB(Dictionary size), 273(Word size), Solid, Compress shared files. How can I do this?
-
pras92 about 11 yearsActually, i'm not exposed to CLI. So would you please tell me the exact code to perform this? Also, if we are to keep maxdepth = 1, won't the files in the subfolders be excluded? And there is no mention of the settings that i intend to use. How do i specify that?
-
pras92 about 11 yearsI already checked that First link. It makes the output file to be in one single zip file, doesn't it? But Unfortunately, I don't want it that way. Thanks for the second link. Though it might take me weeks to find what i want by myself, I've no other way. If you already know how to do code to meet my requirements, please advise so.
-
Roney Michael about 11 years@prashanth: The first link had actually worked fine for me. I just made a bat file with the contents as
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
and put in in myMAIN
folder. When I ran it, I got each folder in a separate 7z file. -
martineau about 11 years@prashanth: You'll need to use the command-line version of 7zip, the usage of which is documented in the 7zip Help file that comes with the executable -- should be listed under "Programs" from the Start menu.
-
Karan about 11 yearsp7zip of course is the command line version of 7-Zip for Unix/Linux. 7za.exe is what you'd use if you were on Windows.
-
pras92 about 11 yearsThank You Ron. I didn't read it properly. It works like a charm now. You saved me a lot of time. :)
-
Roney Michael about 11 years@prashanth: Happy to help. :) Please do mark the answer as accepted if you're happy with it.
-
pras92 about 11 yearsOh. I didn't know that, expect for voting the answer. Thank You.