Sign in to follow this  
Followers 0
computergroove

Adding a " " around a variable if there is at least one space in the name

9 posts in this topic

#1 ·  Posted (edited)

I need to send a command to Media Player Classic where I tell it the name of the video file I want it to play. My script works now if the video file does not have any spaces. If I can surround the file name with " then it will work. How do I add " to the following?

                Run (@ScriptDir & "MPC-HCmpc-hc64.exe /play /fullscreen /close "&$video_file&"")

So $video_file will come out looking like "Dragon Slayer.mpg" instead of Dragon Slayer.mpg

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

"&'"'&$video_file&'"'&
Run (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close "&'"'&$video_file&'"'")

Returns error: syntax error (illegal character)

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This should work fine:

Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"')

Edit: JohnOne suggested a nice approach to solve the problem ;)

Cheers,

sahsanu

Edited by sahsanu

Share this post


Link to post
Share on other sites

Opt("ExpandVarStrings", 1)
$video_file =  "Dragon Slayer.mpg"
ConsoleWrite("@lf@Here the string:@lf@")
ConsoleWrite("@ScriptDir@\MPC-HC\mpc-hc64.exe /play /fullscreen /close ""$video_file$""")
         Run("@ScriptDir@\MPC-HC\mpc-hc64.exe /play /fullscreen /close ""$video_file$""")
ConsoleWrite("@lf@@lf@")


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

This should work fine:

Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"')

Edit: JohnOne suggested a nice approach to solve the problem ;)

Cheers,

sahsanu

This worked. Thanks everyone


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0