Page 1 of 2
[SOLVED][LINUX] Parse/run rename.sh inside archive ?
Posted: February 10th, 2015, 2:30 pm
by synci
Hey guys,
atm i get much content (mostly tv series) that contains a file named "sffdgdfdhhj45657rtghdg" without extension like *.mkv.
But there is also a rename.sh file inside, can anybody help to to post processing that ?
When i run that rename.sh file everything runs fine and the file gets renamed correctly, but i would prefer the auto mode
One way could be to simply rename the biggest file as same as the nzb name is, but as i said already there is no extension given to that file.
There is a *nzbget* offical script available that can handle exactly this, it doesnt run that rename.sh file, it reads and uses the name inside that rename.sh file.
I dont know if its allowed to link here ?
Sorry for my english
Thanks !
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 10th, 2015, 3:53 pm
by sander
Can you post a link to such a .NZB?
Can you post a link to that nzbget script?
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 10th, 2015, 4:22 pm
by synci
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 10th, 2015, 5:07 pm
by sander
Yes, NZB via PM.
Can you post the line from such rename.sh containing the "mv" command? Preferrably a small download.
I had a look at the github code, and this is the core part:
Code: Select all
if rename_file:
rename_lines = [line.strip() for line in open(rename_file)]
for line in rename_lines:
cmd = filter(None, re.split('(?:mv|Move)\s+(\S+)\s+(\S+)',line))
if len(cmd) == 2 and os.path.isfile(os.path.join(dirname, cmd[0])):
orig = os.path.join(dirname, cmd[0])
dest = os.path.join(dirname, cmd[1].split('\\')[-1].split('/')[-1])
if os.path.isfile(dest):
continue
print "[INFO] Renaming file %s to %s" % (orig, dest)
try:
os.rename(orig, dest)
except Exception,e:
print "[ERROR] Unable to rename file due to: %s" % (str(e))
sys.exit(NZBGET_POSTPROCESS_ERROR)
So: find the line with "mv" (linux/OSX) or "Move" (windows). In there, get orig and dest filename (some magic handling on dest name), and do the rename.
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 10th, 2015, 5:13 pm
by synci
NZB (1,4GB dl) sent via PM.
Thanks !!!
Here the rename.sh:
Code: Select all
#!/bin/bash
mkdir Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON
mv 27.06.2014.1 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/breaking.bad.s05e09.german.dl.720p.bluray.x264-intention.nfo
mv 27.06.2014.2 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/breaking.bad.s05e09.german.dl.720p.bluray.x264-intention.mkv
mv 27.06.2014.3 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs
mv Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/27.06.2014.4 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/breaking.bad.s05e09.german.dl.1080p.bluray.x264-intention.idx
mv Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/27.06.2014.5 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/breaking.bad.s05e09.german.dl.1080p.bluray.x264-intention.subs.sfv
mv Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/27.06.2014.6 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/breaking.bad.s05e09.german.dl.1080p.bluray.x264-intention.sub
mv Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/27.06.2014.7 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/breaking.bad.s05e09.german.dl.1080p.bluray.x264-intention-eng.idx
mv Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/27.06.2014.8 Breaking.Bad.S05E09.German.DL.720p.BluRay.READ.NFO.x264-iNTENTiON/Subs/breaking.bad.s05e09.german.dl.1080p.bluray.x264-intention-eng.sub
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 10th, 2015, 5:35 pm
by sander
Does one rename.sh file contain just one, or more mv commands?
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 12:50 am
by synci
I forgot to give that information at the beginning.
Yes, its not only the main video file with that crypted name without extension, all files like .nfo, .sub ... have names like that.
And yes, the rename.sh contains all needed mv commands, for each file, like i posted before.
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 6:35 am
by sander
OK, so a rename.sh contains a complete list of mv-commands. That's clear.
The NZB you PMed is not downloadable for me, so I'll wait for you to send me a downloadable one.
PS: I wonder why this renaming is done. One thing comes to mind: circumventing early rar scanning ... which is what SABnzbd's feature Unwanted Extensions does ... hmmmm
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 7:08 am
by sander
I found more of those downloads:
http://nzbindex.com/search/?poster=usen ... %3E&more=1
The MUST_READ.txt says:
Auf win_click2rename.bat klicken und die Filename werden richtig zurückbennant.
lINUX ...
Linux_2Rename.sh doppelklicken und dann ... im Terminal ausführen wählen
Falls das nicht klappt muss Linux_2Rename.sh vorher nochmal ausführbar gemacht werden.
Dazu mit rechts die Eigenschaften aufrufen und im Reiter Zugriffsrechte das Häckchen bei
Als Programm ausführen anklicken.
Dann wie oben ... Doppelklich und .. im Termial ausführen
Viel Spass
Wow ... running an executable that you just downloaded ...
... if you dare that, you could write a post-processing script that just finds the *.sh resp *.bat and executes it ....
I really understand why the nzbget script filters the mv commands from the script and executes it own.
TBC ...
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 7:22 am
by synci
Okay, so as i understand you are just before completing the script ?
Im not able to script something like that, donation is okay ?
You dont need any nzb now ?
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 8:39 am
by sander
I have it working. Solved two bugs in the original script.
Here it is:
https://raw.githubusercontent.com/sande ... eRename.py
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 9:28 am
by synci
Wow thank you so much !!! (Will send you a PM too regarding don)
Just one question, your scripts works great but only when i run it via SSH (/usr/bin/env python SafeRename.py Release)
Its a problem on my OMV machine for sure, but i think its a simple problem you can solve within seconds.
SAB says "Exit(127) /usr/bin/env: python : No such file or directory"
I already tried to edit the python part in your scripts line 1, but as i said it works via SSH.
So "/usr/bin/env python" is possible and works.
Any ideas ?
Thanks !!!
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 9:37 am
by sander
What is the output of the following commands on your Linux system:
Code: Select all
which python
which env
/usr/bin/env python --version
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 9:38 am
by synci
Code: Select all
root@omv:~# which python
/usr/bin/python
root@omv:~# which env
/usr/bin/env
root@omv:~# /usr/bin/env python --version
Python 2.7.3
Re: [LINUX] Run rename.sh inside archive ?
Posted: February 11th, 2015, 10:02 am
by sander
Strange.
Post the output of
Example:
Code: Select all
$ ls -al SAB-SafeRename.py
-rwxrwxr-x 1 sander sander 1858 feb 11 14:37 SAB-SafeRename.py
Check first line:
Code: Select all
$ head -1 SAB-SafeRename.py
#!/usr/bin/env python
What if you replace the first line with