Scripting help required to move file up one level

Come up with a useful post-processing script? Share it here!
Post Reply
themugger
Release Testers
Release Testers
Posts: 30
Joined: June 11th, 2008, 10:44 am

Scripting help required to move file up one level

Post by themugger »

Hi There, i currently use the script below to convert my tv episodes to ipod format.

Ive been having a problem where all files in the show directory are all converted every single time, so i decided to have sab create a temp directory when it downloads the show . for example

Code: Select all

\\nas\tv\show name\season1\convert\
convert being the temp folder. everything works well and the conversion takes place. the problem is the episode stays in the convert folder and i would like to move it up one level to to

Code: Select all

\\shinenas\tv\show name\season1\
i tried doing this in my scipt with move

Code: Select all

"%dirname%\*.mkv ..\
but this moves the file up one level in the current directory that dos is in which is on the local machine. as you can see above i want to move the file up one level on the network and i cant set a network address as the current directory in dos. One thing i thought of was to somehow take out the

Code: Select all

\convert
out of the directory name and tell the file to move there but i dont know how to do that.....

here is my current script anyway, i appreciate any help any one can give me.... thankyou.

Code: Select all

set name=%3
set name=%name:"=%

REM rename isos or bins

set dirname=%1
set dirname=%dirname:"=%

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%


for /R "%dirname%" %%f in (*.mkv) do e:\handbrake\HandBrakeCLI.exe --input "%%f" --output "\\Shinenas\tv\Ipod\%name%.mp4" --preset="iPhone & iPod Touch" 
for /R "%dirname%" %%f in (*.avi) do e:\handbrake\HandBrakeCLI.exe --input "%%f" --output "\\Shinenas\tv\Ipod\%name%.mp4" --preset="iPhone & iPod Touch" 
for /R "%dirname%" %%f in (*.mov) do e:\handbrake\HandBrakeCLI.exe --input "%%f" --output "\\Shinenas\tv\Ipod\%name%.mp4" --preset="iPhone & iPod Touch"

move *.avi ..\
move *.mkv ..\
move *.mpg ..\
move *.mp4 ..\
move "%dirname%\*.mov
minimeh
Newbie
Newbie
Posts: 34
Joined: March 26th, 2010, 12:42 pm

Re: Scripting help required to move file up one level

Post by minimeh »

Given your existing code, this should do what you want:

Code: Select all

move "%dirname%\*.avi "%dirname%\..
move "%dirname%\*.mkv "%dirname%\..
move "%dirname%\*.mpg "%dirname%\..
move "%dirname%\*.mp4 "%dirname%\..
move "%dirname%\*.mov "%dirname%\..
The point being to dereference from the network path (%dirname%) not the current directory ( "..\" which is an alias for ".\..", the single dot representing the current directory).

Cheers.
themugger
Release Testers
Release Testers
Posts: 30
Joined: June 11th, 2008, 10:44 am

Re: Scripting help required to move file up one level

Post by themugger »

Hello mate, thanks for that..... it looks very  clear what you have said. unfortunetly it didnt work but i think it is very close... here is the output on the log

Code: Select all

e:\SABNzbd>move "\\shinenas\TV\current\Test\Season 1\convert\*.mov "\\shinenas\TV\current\Test\Season 1\convert\.. 
The filename, directory name, or volume label syntax is incorrect
Thanks for your help so far mate.
themugger
Release Testers
Release Testers
Posts: 30
Joined: June 11th, 2008, 10:44 am

Re: Scripting help required to move file up one level

Post by themugger »

ignore me, i just needed to add some quotes and all seems to be working now. one more question though if you dont mind?


what would i need to put in the script to delete the convert folder i just created?

Thanks
minimeh
Newbie
Newbie
Posts: 34
Joined: March 26th, 2010, 12:42 pm

Re: Scripting help required to move file up one level

Post by minimeh »

themugger wrote: Hello mate, thanks for that..... it looks very  clear what you have said. unfortunetly it didnt work but i think it is very close... here is the output on the log

Code: Select all

e:\SABNzbd>move "\\shinenas\TV\current\Test\Season 1\convert\*.mov "\\shinenas\TV\current\Test\Season 1\convert\.. 
The filename, directory name, or volume label syntax is incorrect
Thanks for your help so far mate.
Hmm, you have a mismatched quotes. The original code has a strange, to me anyway, code that appeared to tack a quote onto %dirname%. On further examination, I guess not. So the quotes that I put in, which were intended to match the appended quotes, causes the mismatch (if that makes any sense  :P) .

Try this instead:

Code: Select all

move "%dirname%"\*.avi "%dirname%"\..\
move "%dirname%"\*.mkv "%dirname%"\..\
move "%dirname%"\*.mpg "%dirname%"\..\
move "%dirname%"\*.mp4 "%dirname%"\..\
move "%dirname%"\*.mov "%dirname%"\..\
Should that work okay, you might consider removing

Code: Select all

set name=%name:"=%
set dirname=%dirname:"=%
I'm not familiar with what these are supposed to do, but assumed that they append a quote to their respective variables. If they don't (and then what are they doing??), then just dump them and make sure that you quote every reference to %name% and %dirname%, which it appears you have already done.

Cheers!
minimeh
Newbie
Newbie
Posts: 34
Joined: March 26th, 2010, 12:42 pm

Re: Scripting help required to move file up one level

Post by minimeh »

themugger wrote: ignore me, i just needed to add some quotes and all seems to be working now. one more question though if you dont mind?


what would i need to put in the script to delete the convert folder i just created?

Thanks
Assuming dirname=\\shinenas\tv\show name\season1\convert, this should work:

Code: Select all

rmdir /s /q "%dirname%"
Cheers!
themugger
Release Testers
Release Testers
Posts: 30
Joined: June 11th, 2008, 10:44 am

Re: Scripting help required to move file up one level

Post by themugger »

that did the trick, thanks mate
Post Reply