Champak Posted May 5, 2006 Share Posted May 5, 2006 (edited) At the end of my script I a program that will open up a file that is being called by a variable. However, the names of the files may contain spaces. The file is not being opened because of that, however, if the path to the app has spaces, the app is still opened. That does not make any sense to me. This is the code. $program = "C:\Additions\Studio Session\Sequoia\Sequoia.exe" $file = "C:\Test Test.wav" Run($program & ' ' & $file) Am I doing something wrong, or is this normal? I did do a search for this and couldn't get an answer. Edited May 5, 2006 by Champak Link to comment Share on other sites More sharing options...
Simucal Posted May 5, 2006 Share Posted May 5, 2006 Have you tried doing this on a cmd console yourself? Maybe wrapping your $file in quotes. $file = '"C:\Test Test.wav"' AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 5, 2006 Moderators Share Posted May 5, 2006 Look at FileGetShortName() in the Beta Help file. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 5, 2006 Author Share Posted May 5, 2006 Simucal: Funny, I did that with the double quotes and it didn't work, buy now I tried it with the single and it does. However, the example you are seeing is just an example, I'm actually calling it like " & MasterMixdown2 & ", and it wont work with that. I put the single quotes after, before the "&" and after and before the spaces surrounding the "space" around the "&". Example of the actual thing. $file = "$someVariable & \Mixdown - "' & $MasterMixdown2 & '"." & $FileExtension Any other idea? SmOke_N: I see what you are speaking about. Exactly which file out of the beta am I supposed to copy for this? Is it like what I did with the _PathSplit where I just coppied one file to get the function? Thanks. Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2006 Share Posted May 5, 2006 maybe $file = $someVariable & "\Mixdown - " & $MasterMixdown2 & "." & $FileExtension ; Or $file = FileGetShortName($someVariable & "\Mixdown - " & $MasterMixdown2 & "." & $FileExtension) you made need to look at the spaces between the actual words/variables to test msgbox(0,0, $someVariable & "\Mixdown - " & $MasterMixdown2 & "." & $FileExtension) 8) Link to comment Share on other sites More sharing options...
Champak Posted May 5, 2006 Author Share Posted May 5, 2006 (edited) I got pie on my face now :"> , it wasn't specifying the right file name. An extra space was happening in the title that I didn't realize right after the "Mixdown - ", that was causing the problem. I am using $file = FileGetShortName($someVariable & "\Mixdown - " & $MasterMixdown2 & "." & $FileExtension)for anyone else. I didn't bother to go back and test $file = $someVariable & "\Mixdown - "' & $MasterMixdown2 & '"." & $FileExtensionbut it may still work also...hell, the original thing may work if it weren't for my blindness.I figured this out with Valuators genius simplicity in dignosing the problem and using the msg. Funny, I never saw this thing as a "tool" before, now I have seen the light .Now it's just a matter of grabbing the damn path($someVariable) as being discussed on another post here. Edited May 5, 2006 by Champak Link to comment Share on other sites More sharing options...
MHz Posted May 5, 2006 Share Posted May 5, 2006 I would advise using quotes instead of using FileGetShortName to run the file. Using FileGetShortName is just avoiding using quotes. To ensure success with FileGetShortName failure, then you need to backup to a quote method anyway. So why not do it the right way, just as anyone who uses a DOS command needs to do. Example: $filelong = @ScriptDir & '\file.exe' $fileshort = FileGetShortName($filelong) If @error Then $fileshort = '"' & $filelong & '"' EndIf Looks tacky and unreliable to use IMO. FileGetShortName should not be used as a standard. Link to comment Share on other sites More sharing options...
Champak Posted May 5, 2006 Author Share Posted May 5, 2006 I really don't comprehend why I need to do this, but never question the wiser. Your wish has been granted . Thanks. Link to comment Share on other sites More sharing options...
MHz Posted May 5, 2006 Share Posted May 5, 2006 I really don't comprehend why I need to do thisA member was shown to use FileGetShortName and was disappointed from the results as posted here. If FileGetShortName fails for any reason, then the parameter is returned. @Comspec or other programs may error for this so using a full path with quotes will prevent such from becoming an issue. The difference: ; This can fail under certain conditions so needs error checking $file = FileGetShortName('c:\file name.txt') ; Below requires no error checking $file = '"c:\file name.txt"' Using quotes to use spaces in strings makes more reliable code. Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2006 Share Posted May 5, 2006 @MHz I use filegetshortname due to other errors... not just due to spacing ( i thought) I read the post you referred to by randallc... its seems his problem was the file did not exist, thus the error however, can you tell why this has problems $file_name = @ProgramFilesDir &"\autoit3\autoit3help.au3" Run(@ComSpec & " /c Start " & $file_name, "", @SW_HIDE) sleep(3000) $file_name = FileGetShortName(@ProgramFilesDir & "\autoit3\autoit3help.au3") Run(@ComSpec & " /c Start " & $file_name, "", @SW_HIDE) and the second does not Thanks 8) Link to comment Share on other sites More sharing options...
MHz Posted May 5, 2006 Share Posted May 5, 2006 however, can you tell why this has problemsAs from XP SP2 onwards, the DOS Start command uses the 1st set of quotes to specify the title of the Comspec window.Valuater,This does not mean you should use FileGetShortName as default for everything else. Examples I see of FileGetShortName uses no error checking so is poor code compared to using double quotes for paths with spaces. I rarely use FileGetShortName, and see no need to teach others to use it, if not required.What happened to Randall was avoidable if it was not shown to him, to use FileGetShortName as like some kind of standard. Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2006 Share Posted May 5, 2006 As from XP SP2 onwards, the DOS Start command uses the 1st set of quotes to specify the title of the Comspec window.Valuater,This does not mean you should use FileGetShortName as default for everything else. Examples I see of FileGetShortName uses no error checking so is poor code compared to using double quotes for paths with spaces. I rarely use FileGetShortName, and see no need to teach others to use it, if not required.What happened to Randall was avoidable if it was not shown to him, to use FileGetShortName as like some kind of standard.Thanks8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now