Page 1 of 1

Sometimes I get "" Sometimes not

Posted: 01 Mar 2011 12:19
by zzyzxroad
I am using a batch to encode videos for virtualdub. I have used this scrip before and it works no problem. I have tried the last several days to make the code work using other tasks, and today I just realized that the script makes quotations when I didnt ask for them.

here is a small part of the script:

rem Add to scheduler batch
echo if exist %1.part1.avs J:\DESHAKER\VirtualDub\deinterlace1.bat %1 > J:\DESHAKER\VirtualDub\Picker.bat

echo if exist %1.part2.avs J:\DESHAKER\%1.deshake.bat %1.avi >> J:\DESHAKER\VirtualDub\Picker.bat

echo if exist %1.part3.avs J:\DESHAKER\VirtualDub\deshakecut.bat %1.avi.avi >> J:\DESHAKER\VirtualDub\Picker.bat


An this is what I NOW get, what I never used to get:
if exist "J:\DESHAKER\5 second.MTS".part1.avs J:\DESHAKER\VirtualDub\deinterlace1.bat "J:\DESHAKER\5 second.MTS"
if exist "J:\DESHAKER\5 second.MTS".part2.avs J:\DESHAKER\"J:\DESHAKER\5 second.MTS".deshake.bat "J:\DESHAKER\5 second.MTS".avi
if exist "J:\DESHAKER\5 second.MTS".part3.avs J:\DESHAKER\VirtualDub\deshakecut.bat "J:\DESHAKER\5 second.MTS".avi.avi


Look where the quotations are, they are not around the complete filename. I actually didnt want them at all.

What could be the cause for this?

Re: Sometimes I get "" Sometimes not

Posted: 01 Mar 2011 12:56
by !k
The white spaces.
Use

Code: Select all

"%~1.part1.avs"

Re: Sometimes I get "" Sometimes not

Posted: 01 Mar 2011 13:45
by zzyzxroad
Ahh, a space!

Ok, but before I go and change several lines of code, if I use "%~1" and the filename doesnt have an space, will it still work?

Re: Sometimes I get "" Sometimes not

Posted: 01 Mar 2011 14:52
by aGerman
Yes, it will.

My recommendations:
-always enclose pathes in double quotes to protect you from errors caused by spaces
-write redirections in an opposite style to protect you from errors caused by numbers on the line end
-use EnableDelayedExpansion to protect you from errors caused by special characters (e.g. jekyll & hyde.MTS)

Try

Code: Select all

set "file=%~1"

setlocal enabledelayedexpansion

>"J:\DESHAKER\VirtualDub\Picker.bat" echo if exist "!file!.part1.avs" "J:\DESHAKER\VirtualDub\deinterlace1.bat" "!file!"
>>"J:\DESHAKER\VirtualDub\Picker.bat" echo if exist "!file!.part2.avs" "J:\DESHAKER\!file!.deshake.bat" "!file!.avi"
>>"J:\DESHAKER\VirtualDub\Picker.bat" echo if exist "!file!.part3.avs" J:\DESHAKER\VirtualDub\deshakecut.bat" "!file!.avi.avi"

endlocal


Regards
aGerman

Re: Sometimes I get "" Sometimes not

Posted: 02 Mar 2011 13:25
by zzyzxroad
I tried it but the dos promt writes everythiing super fast and never stops. It just keeps writing the same commands.

EDIT: No wait, it works! I had to change a few things with EXIT and GOTO:EOF


Thanks for the help!!!