if statement - Can't put a certain expression in IF clause in batch file -
the following works fine:
@echo off youtube-dl --output d:\path\%%(title)s.%%(ext)s -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq
i can add if
clause (and expected 'hi'):
@echo off if 1==1 ( echo hi ) youtube-dl --output d:\path\%%(title)s.%%(ext)s -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq
but when put youtube-dl
in if
clause, doesn't work. s.%(ext)s unexpected @ time.
, without hi
.
@echo off if 1==1 ( echo hi youtube-dl --output d:\path\%%(title)s.%%(ext)s -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq )
same thing if put output path in variable:
@echo off set output=d:\path\%%(title)s.%%(ext)s if 1==1 ( echo hi youtube-dl --output %output% -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq )
the variable not problem, following works fine:
@echo off set output=d:\path\%%(title)s.%%(ext)s if 1==1 ( echo hi ) youtube-dl --output %output% -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq
how put thing in if
clause?
thanks iridium solution. brackets inside if()
need escaped, (
becomes ^(
, )
becomes ^)
.
@echo off if 1==1 ( echo hi youtube-dl --output d:\path\%%^(title^)s.%%^(ext^)s -f bestaudio https://www.youtube.com/watch?v=j9bjjejk2dq )
Comments
Post a Comment