clinton-hall / GetScripts

A Collection of NZBGet Post-Process Scripts
GNU General Public License v2.0
100 stars 39 forks source link

Handle rared rename.sh file #6

Closed w00druff closed 9 years ago

w00druff commented 9 years ago

Some boards are packing the rename.sh file now- within a password protected rar archive named What.rar

There is a „a_Linux_2rename.sh“ file in main dir now containing this: unrar x -p73522169 What.rar ./What.sh

Now that What.sh file is our rename script containing our known move commands.

clinton-hall commented 9 years ago

ok... give this ago...

I don't know what will happen if they change the naming convention from what you have described...

w00druff commented 9 years ago

Thanks, but it doesnt work :( p = Popen(cmd2, stdout=devnull, stderr=devnull) cmd2 is not defined, i have tried it with cmd instead. Then it tells me that he is extracting the "a_Linux_2rename.sh" file but nothing happens.

clinton-hall commented 9 years ago

hmmm.. try this last one..

w00druff commented 9 years ago

Thanks, extracting works now, but then i get this. [INFO] Extraction was successfull Traceback (most recent call last): File "/home/sabnzbd/.sabnzbd/scripts/SafeRename.py", line 147, in rename_script(dirname) File "/home/sabnzbd/.sabnzbd/scripts/SafeRename.py", line 127, in rename_script newfile = os.path.splitext(cmd[-1])[0] + '.sh' IndexError: list index out of range

clinton-hall commented 9 years ago

ok... sorry for that. I reset the cmd before trying ti build the new file name. This last one should get closer...

w00druff commented 9 years ago

No problem, thank you ! I think we get a bit closer to the goal :) Now i get "extraction successfull" but no renamings done.

Just to check, this is the content of the extracted "What.sh" file:

!/bin/bash

mkdir Testdir mv 05.02.2015.1 Test1/test.nfo mv 05.02.2015.2 Test1/testmovie.mkv mv 05.02.2015.3 Test1/Subs mv Test1/Subs/05.02.2015.4 Test1/Subs/test.sub mv Test1/Subs/05.02.2015.5 Test1/Subs/test.idx

clinton-hall commented 9 years ago

ok... can you test this?

w00druff commented 9 years ago

Same result, extraction successfull but nothing further ... It is slowly getting me uncomfortable because of your time :( What about just running that What.sh file if there just mv/move/mkdir commands in within THIS dir ?

clinton-hall commented 9 years ago

ok, can you try again. This won't work yet, but it should add new logging that will help show where this goes wrong.

I'm expecting it is looking for the wrong file, but I can't see why right now.

clinton-hall commented 9 years ago

and don't be uncomfortable about this... This is my project and I only spend what time I can...

w00druff commented 9 years ago

[INFO] Extracting file /media/ed602aaf-dacf-4178-bca6-d6652f1d95d6/DATA/_DOWNLOAD/532ff4ee_0f5c1c3c_9b29df68_bf88dcd-u4e/532ff4ee_0f5c1c3c_9b29df68_bf88dcd/a_Linux_2rename.sh with command unrar x -p2540117263 What.rar [INFO] Extraction was successfull [INFO] Checking for file /media/ed602aaf-dacf-4178-bca6-d6652f1d95d6/DATA/_DOWNLOAD/532ff4ee_0f5c1c3c_9b29df68_bf88dcd-u4e/532ff4ee_0f5c1c3c_9b29df68_bf88dcd/What.sh [INFO] Reading lines from /media/ed602aaf-dacf-4178-bca6-d6652f1d95d6/DATA/_DOWNLOAD/532ff4ee_0f5c1c3c_9b29df68_bf88dcd-u4e/532ff4ee_0f5c1c3c_9b29df68_bf88dcd/What.sh

clinton-hall commented 9 years ago

sorry for the delay here... but this project does come second to life :) I recon I found the issue. This should hopefully make this work, but in any case I have increased the logging (for now) to try and see where it falls over if it doesn't work.

w00druff commented 9 years ago

I can check in ~2hours, thanks mate :)

w00druff commented 9 years ago

Ill post log after parsing and i can see the problem. In our What.sh file is a mkdir command ... he wants to make the dir DIRXXXXXXX. So renaming doesnt work because of the missing dir i think ?

[INFO] Renaming file /media/ed602aaf-dacf-4178-bca6-d6652f1d95d6/DATA/_DOWNLOAD/532ff4ee_0f5c1c3c_9b29df68_bf88dcd-u4e/532ff4ee_0f5c1c3c_9b29df68_bf88dcd/05.02.2015.1 to /media/ed602aaf-dacf-4178-bca6-d6652f1d95d6/DATA/_DOWNLOAD/532ff4ee_0f5c1c3c_9b29df68_bf88dcd-u4e/532ff4ee_0f5c1c3c_9b29df68_bf88dcd/DIRXXXXXXX/xxxxxxx.nfo [ERROR] Unable to rename file due to: [Errno 2] No such file or directory

clinton-hall commented 9 years ago

ok... added the mkdir command... can't believe I missed that!

w00druff commented 9 years ago

Okay mkdir worked and nearly all files got renamed :)

Here the What.sh file with notes what worked:

!/bin/bash

mkdir Test CHECK ! mv 05.02.2015.1 Test/test.nfo CHECK ! mv 05.02.2015.2 Test/Test.mkv CHECK ! mv 05.02.2015.3"SPACESPACE"Test/Subs NOPE ! mv Test/Subs/05.02.2015.4"SPACESPACE"Test/Subs/Test.sub NOPE ! mv Test/Subs/05.02.2015.5"SPACESPACE"Test/Subs/Test.idx NOPE !

Maybe because there are two spaces in the other mv commands ? EDIT Github ignores the two spaces, i "highlighted" them.

clinton-hall commented 9 years ago

the problem was it only renamed files, not directories... this should work now

clinton-hall commented 9 years ago

sorry for the lengthy process here...

w00druff commented 9 years ago

Okay i can try in few hours, thanks ! You do not have to apologize, I appreciate your time !!!

w00druff commented 9 years ago

Okay mate, works very good, thanks a lot ! Last question, is it possible for you to chmod 775 all files and dirs after successfull rename ? And maybe also a cleanup of all .sh, .rar, .zip, .bat files ? :)

clinton-hall commented 8 years ago

Finally added...