Page 1 of 1

windows script to move VIDEO_TS to proper folder

Posted: July 13th, 2009, 11:53 pm
by caykroyd
Some downloads add a subfolder then the VIDEO_TS folder

ex:  P:\Movies\moviename\unwantedmoviefolder\VIDEO_TS

Is there a way in windows to check if this unwanted folder is in the %1 directory and move the VIDEO_TS folder to the %1 directory and delete the unwanted folder?

Re: windows script to move VIDEO_TS to proper folder

Posted: July 14th, 2009, 7:44 am
by doubledrat
if you run this as part of your postprocessing it should do what you want

Code: Select all

set dirname=%1
set dirname=%dirname:"=%
set name=%3
set name=%name:"=%
set nbID=%4
set DLTYPE=%5


for /D /R "%dirname%" %%f in (VIDEO_TS*) do move "%%f" "%dirname%\"

Re: windows script to move VIDEO_TS to proper folder

Posted: July 14th, 2009, 11:39 pm
by caykroyd
Thanks.  That worked.  But I can't seem to delete the old directory

This is my output:

Code: Select all

Q:\Movies\movietest>set dirname=
Q:\Movies\movietest>set dirname="=
Q:\Movies\movietest>set dirname=Q:\Movies\movietest
Q:\Movies\movietest>set name=
Q:\Movies\movietest>set name="=
Q:\Movies\movietest>set nbID=
Q:\Movies\movietest>set DLTYPE=
Q:\Movies\movietest>for / %f in (VIDEO_TS*) do move "%f" "Q:\Movies\movietest\"
Q:\Movies\movietest>move "Q:\Movies\movietest\somefolder\VIDEO_TS" "Q:\Movies\movietest\"
So, I tried to add the following to remove the "somefolder", but I cant' seem to get it set correctly.

Code: Select all

set oldfolder=%%f
set oldfolder=%oldfolder:VIDEO_TS=%
echo old folder is %oldfolder%
and here is the output (%oldfolder is not getting set properly)

Code: Select all

set oldfolder=Q:\Movies\movietest\somefolder\VIDEO_TS
set oldfolder==
echo old folder is = 
Can anyone help me with this?

Re: windows script to move VIDEO_TS to proper folder

Posted: July 15th, 2009, 8:28 am
by doubledrat
the %%f variable is only addressable on the "for" line.  If you want to do something more than 1 line's worth I would suggest you call a subroutine.  like this

Code: Select all

set dirname=%1
set dirname=%dirname:"=%
set name=%3
set name=%name:"=%
set nbID=%4
set DLTYPE=%5


for /D /R "%dirname%" %%f in (VIDEO_TS*) do CALL :moveVTS "%%f"
GOTO :EOF

:moveVTS
REM note %%f is now %1 in the context of this subroutine and is surrounded by ""
move %1 "%dirname%\"
REM more commands here
GOTO :EOF
code untested!  it may have typos