Page 1 of 1

Multiple Folders into Multiple 7zip Files with Encryption

Posted: Thu Jun 29, 2017 2:21 pm
by Memoox
Hello everyone.

I'd like to ask for your help for my files at work. I have multiple folders each containg information from projects. I just learned how to compress them into 7z in the command line. We use windows at work but my work laptop is very slow, so i bring the folders home and do the compression here. I use this:

7za a -t7z -m0=lzma -mx=9 -mhe=on -pMy_password ProjectFolder01.7z ProjectFolder01

All good there, but i have around 200 folders, and i tried to use a FOR but I only find examples for files and not folders. The whole idea is to compress each folder, with encryption, keep its original name, but not all of them at once, that's why I thought of a FOR loop, that way the pc creates a 7z file using all resources (and disk writing) without any problems.

Thanks for your help!

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Thu Jun 29, 2017 2:54 pm
by SprinterDriver
7zip accept using a listfile as input. I recommend that before doing multiple calls to build up the 7z file.

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Thu Jun 29, 2017 11:13 pm
by Memoox
SprinterDriver wrote:7zip accept using a listfile as input. I recommend that before doing multiple calls to build up the 7z file.
Hey SprinterDriver... I think if you put two or more directories in the input section, all of them go to a single 7z file... that's not what I'm after. I do this in Windows using this:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"

But of course, there's no encryption and the syntax is for the windows command prompt. I was looking for the same thing in bash.

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Fri Jun 30, 2017 12:23 am
by jimallyn
If you can do it in Windows command line, you can surely do it in Linux command line. Download the book found at the link below, and you should be able to crank out a command to do that pretty quickly. And if not, I bet one of the wizards here on the forums can give you a one liner to do that.

http://linuxcommand.org/tlcl.php

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Sat Jul 01, 2017 12:16 pm
by Memoox
jimallyn wrote:If you can do it in Windows command line, you can surely do it in Linux command line. Download the book found at the link below, and you should be able to crank out a command to do that pretty quickly. And if not, I bet one of the wizards here on the forums can give you a one liner to do that.

http://linuxcommand.org/tlcl.php
Thanks for reference jimallyn. I've read the guide, and like I said, can't find a correct syntaxis to use for directories. I counts variables like counters and things... but folders??.

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Sat Jul 01, 2017 1:27 pm
by phd21
Hi "Memoox",

I just read your post and the good replies to it. Here are my thoughts on this as well.

I would recommend installing "PeaZip" in both your MS Windows and Linux computers which can easily do this for you using a nice desktop application. Just right click in the top box to pick folders and files, or use the toolbar options..
http://www.peazip.org/

Linux Download - In Linux I install PeaZip using the GTK ".deb" file which works better for me than the QT version, but you can try either one.
http://www.peazip.org/peazip-linux.html

FYI: You can also use an Internet "cloud" service to sync your folders/files from work computers or home computers (using this provides a backup too). like excellent "pCloud" (10+gb free), "Mega.nz" (encrypted 50gb free), Google Drive (15 gb free), DropBox (2gb free), etc... Theoretically, if nobody knows your Cloud provider's login password, whether their service is encrypted or not, your files are secure. You can also install and use Cryptomator.

Encrypt Your Cloud Files With Cryptomator (Open Source, Cross-Platform)
http://www.webupd8.org/2016/04/encrypt- ... -with.html

Hope this helps ...

Click image to view larger size, or right click open in a new tab, then you can click again to enlarge or shrink it.
PeaZip_Showing_SplitOptions2.jpg

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Sat Jul 01, 2017 2:13 pm
by Flemur
Memoox wrote:that's why I thought of a FOR loop,!
I'm kinda bad and lazy with scripting but pretty good with 'vi', so I'd do a project like that in a very convoluted way:

Code: Select all

ls ProjectFolder* > a  # or some other way of getting the list of directories...
cp a b
vi a  # stick ".7z " at the end of the dir name and "7za a -t7z -m0=lzma -mx=9 -mhe=on -p My_password " in front of it
paste a b > c # file 'c' has two columns made from files a and b.
sh c # would make all the compressed directories
...though I'd look at c ('vi c') before running it.

Re: Multiple Folders into Multiple 7zip Files with Encryption

Posted: Mon Jul 03, 2017 6:00 pm
by Memoox
Thanks fot the replies.

About Peazip... when I was looking for a solution for this, I came across Peazip, which in my opinion is very good. But in this case the whole thing is to use it in the command line or a script.

This weekend I've found to way to do it. After a lot of trying it was simpler that I thought. If you think I should write in form of a tutorial, I will.

So first of all you have to be in the directory. then you use a FOR command like this:

Code: Select all

for d in *;do 7za -m0=lzma -mx=9 -mhe=on -pMy_Password $d.7z $d;done
To break it down a little bit:
For d in * creates the folder list in the directory and stores it "d"
do 7za -m0=lzma -mx=9 -mhe=on -pMy_Password $d.7z $d which the 7z command that creates the 7z file
And then just close the loop.

Hope it helps anyone that has this problem on their hands