SOLVED: Rar/Par folder script - how?

Forum rules
Before you post please read how to get help
Post Reply
danneauxs
Level 1
Level 1
Posts: 42
Joined: Thu Apr 10, 2014 5:37 pm

SOLVED: Rar/Par folder script - how?

Post by danneauxs » Sat Jun 29, 2019 9:32 am

Hi,
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

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

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
Danneauxs

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

mkdir rarred

mv book.rar rarred

cd rarred

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

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
Last edited by danneauxs on Sat Jun 29, 2019 10:18 pm, edited 1 time in total.

rene
Level 12
Level 12
Posts: 4167
Joined: Sun Mar 27, 2016 6:58 pm

Re: Rar/Par folder script - how?

Post by rene » Sat Jun 29, 2019 10:15 am

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.

danneauxs
Level 1
Level 1
Posts: 42
Joined: Thu Apr 10, 2014 5:37 pm

Re: Rar/Par folder script - how?

Post by danneauxs » Sat Jun 29, 2019 11:53 am

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.

Image

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.

Image

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

rene
Level 12
Level 12
Posts: 4167
Joined: Sun Mar 27, 2016 6:58 pm

Re: Rar/Par folder script - how?

Post by rene » Sat Jun 29, 2019 3:52 pm

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.

User avatar
thx-1138
Level 7
Level 7
Posts: 1920
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: Rar/Par folder script - how?

Post by thx-1138 » Sat Jun 29, 2019 4:01 pm

...in 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:

danneauxs
Level 1
Level 1
Posts: 42
Joined: Thu Apr 10, 2014 5:37 pm

Re: Rar/Par folder script - how?

Post by danneauxs » Sat Jun 29, 2019 7:11 pm

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

Post Reply

Return to “Scripts & Bash”