passing variable to run cmd command

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

passing variable to run cmd command

Post by macroman » Sun Jun 12, 2016 10:59 pm

hi all, for sme reason my

Code: Select all

%vid%
not printing out in the cmd window.. but when i

Code: Select all

MDL>%vid%
i see the results just fine... perhaps I need an escape character somewhere? any kind of help is greatly appreciated!

Code: Select all

Run>cmd /k youtube-dl --restrict-filenames -o "P:\youtube\downloads-vid\%(title)s-%(id)s.%(ext)s" "https://youtu.be/%vid%"

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: passing variable to run cmd command

Post by hagchr » Mon Jun 13, 2016 3:30 am

Hi, splitting the line seems to work:

Code: Select all

Let>vid=TestFilm

//Not working
Let>res=Run>cmd /k youtube-dl --restrict-filenames -o "P:\youtube\downloads-vid\%(title)s-%(id)s.%(ext)s" "https://youtu.be/%vid%"
MDL>res

//Working
Let>tmpa=Run>cmd /k youtube-dl --restrict-filenames -o "P:\youtube\downloads-vid\%(title)s-%(id)s.%(ext)s"
Let>tmpb="https://youtu.be/%vid%"
Let>res=%tmpa% %tmpb% 

MDL>res

macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

Re: passing variable to run cmd command

Post by macroman » Mon Jun 13, 2016 3:39 am

hagchr wrote:Hi, splitting the line seems to work:

Code: Select all

Let>vid=TestFilm

//Not working
Let>res=Run>cmd /k youtube-dl --restrict-filenames -o "P:\youtube\downloads-vid\%(title)s-%(id)s.%(ext)s" "https://youtu.be/%vid%"
MDL>res

//Working
Let>tmpa=Run>cmd /k youtube-dl --restrict-filenames -o "P:\youtube\downloads-vid\%(title)s-%(id)s.%(ext)s"
Let>tmpb="https://youtu.be/%vid%"
Let>res=%tmpa% %tmpb% 

MDL>res
yeah for some reason that command line is looking for another % to close the deal... i ended up doing two

Code: Select all

 %(id)s%(id)s
then the single line works fine...

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: passing variable to run cmd command

Post by hagchr » Mon Jun 13, 2016 8:55 am

Another way would have been to define Let>perc=% and then use %perc% instead of % in the formula.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts