Page 1 of 1

SOLVED: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 9:32 am
by danneauxs
I've managed a few very basic scripts to do thing over the years but honestly each time I have to relearn the little I know. If someone could help, and by help I mean do, I'd appreciate it.

I'd like to right click on a folder.
have that folder archived to a single RAR file, with a randomly generated name (date | md5sum) for instance, a password added (hardcoded in the script so it's the same each time) then the pars created (10% redundancy).

Also the resultant files should be in the selected folder rather than the parent folder and preferably placed in a subfolder named I RARPAR

select with right click folder JAMES in parent /home/bob/documents
script would create results in

I Know I'm asking a lot but I simply cannot fathom right now how to do this and my honeydo list this Saturday is huge an I have to run off and take care of it.

Thanks in advance

Not elegant but it works.
rar a -p[smeg] -r10 book.rar

mkdir rarred

mv book.rar rarred

cd rarred

for fname in *.rar
mv $fname 'abook - '"$(pwgen 26 1).rar"

par2 c -r10 *.rar
this 1. rares the selected files 2. creates a folder named "rarred" and moves the book.rar file there and changes to that directory. 3. renames the book.rar to a random 26 character alphanumeric. 4. Creates par2 files with 10% redundancy

Re: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 10:15 am
by rene
The "right click on a folder" bit means we're talking about a graphical file manager and to it specific infrastructure. I myself hardly ever use any garphical file manager so won't be useful but someone who does will need to at least know which graphical file manager. I.e., even besides individual available ones, the default ones for the Cinnamon, MATE and Xfce environments differ.

Re: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 11:53 am
by danneauxs
You are correct, I did not think about that. I'm using caja 1.18.5. There's a folder home/xxx/.config/caja/scripts. Any script put in there is visible when right clicking and selecting scripts.


well crap, I just realized that communicating the location to the script might be hard so yeah probably not.

Is there a way to run the script from a terminal opened to the correct directory instead. I mean I navigate to the directory I want then run the script. So it will rar all the files to the randomly generated filename, set the password, create the par files and move everything to a created subfolder. Of course in whatever order it all needs to be done just so the result correct.


so I'd just run the script name for example rarnpar from the terminal window as shown.

I'm sure I've left something out but not knowing what's needed it's hard to tell what, just like it didn't occur to me to include the file manager info.

Thanks in advance

Re: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 3:52 pm
by rene
As not a MATE user I'll leave this up to someone else to in fact write, but someone posted a set of Caja scripts on the forum before: viewtopic.php?t=219329. A quick glance seems to imply that the script receives the selected items as command-line arguments so it shouldn't be hard to do as you want.

Re: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 4:01 pm
by thx-1138 case it helps, maybe also check xenopeek's scripts in that thread here that i remembered, in a similar context...
Just don't ask me about such though, as my scripting abilities are almost nil... :| :roll:

Re: Rar/Par folder script - how?

Posted: Sat Jun 29, 2019 7:11 pm
by danneauxs
Thanks to all but while the script looked promising, it was too complicated to decipher and did not work in my setup.

As for Caja I'm easily willing to skip a file manager as stated and run a script from the command line. Seems that would negate the caja problem. I can do some of the steps from the command line already, but not all.

Creating the rar file easy.
generating the random string easy.
automatically renaming the existing rar file to the generated name NOPE can't do it.
creating a directory easy
moving files to directory easy.
stringing this all together I have no clue.

Thanks anyway @ thx-1138 and @rene