Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

"&'"'&$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

Link to comment
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@")

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...