Mr.Furious Posted April 15, 2005 Posted April 15, 2005 Is there a way to get this code to still work if the filename has a space in it? $search = FileFindFirstFile("*.imc") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files matched *.imc") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($file) ; Skip directories If StringInStr($attrib, "D") Then ContinueLoop RunWait ("ShelExec "& $file) WEnd ; Close the search handle FileClose($search)
Developers Jos Posted April 15, 2005 Developers Posted April 15, 2005 Try: RunWait ('ShelExec "' & $file & '"') SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 (edited) great that works, so getting a little more serious what is the conversion for this? RunWait ($CmdLine[1] & " " & $CmdLine[2] & $file) Format: $CmdLine[1] $CmdLine[2] $file "ShelExec" "my folder\" "my file.jpg" Edited April 15, 2005 by Mr.Furious
steveR Posted April 15, 2005 Posted April 15, 2005 RunWait ($CmdLine[1] & " " & $CmdLine[2] & " '" & $file & "'") AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 (edited) RunWait ($CmdLine[1] & " " & $CmdLine[2] & " '" & $file & "'")<{POST_SNAPBACK}>Doesn't work as expected opens the folder instead of the file.My brain doesn't seem to be focusing correctly. I can't seem to understand the concept. Edited April 15, 2005 by Mr.Furious
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 THIS WORKS: RunWait ('ShelExec.exe "' & $CmdLine[2] & $file & '"') but I still need to get the initial variable for the external program to work in there. Funny how everything loved life until a folder or file had a space in it.
steveR Posted April 15, 2005 Posted April 15, 2005 It's beacuse of the way DOS commands (and Windows internally) handles file paths. If there are spaces in the path, the cmd path has to be enclosed in quotes. Thats in additon to any quotes needed by the script command. You can also use the short version of the path where quotes aren't needed: "C:\Program Files" becomes C:\PROGRA~1 "C:\Programming codes\My scripts" becomes C:\PROGRA~2\MYSCRI~1 AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
steveR Posted April 15, 2005 Posted April 15, 2005 RunWait ('ShelExec.exe "' & $CmdLine[2] & $file & '" ' & $cmd) AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 Thanks for the tips, I think you misuderstood, I am trying to get this to work:RunWait ('$CmdLine[1] "' & $CmdLine[2] & $file & '"')The variables would = for example "ShelExec.exe" "my folder\" "my file.jpg"arggghh I think white spaces will be chasing me in my dreams tonight.RunWait ('ShelExec.exe "' & $CmdLine[2] & $file & '" ' & $cmd)<{POST_SNAPBACK}>
steveR Posted April 15, 2005 Posted April 15, 2005 (edited) I don't have ShelEec.exe but i got this to work: $cmd1 = "notepad.exe" $cmd2 = "C:\Program Files\" $cmd3 = "test 1.txt" RunWait ($cmd1 & " " & $cmd2 & $cmd3) Edited April 15, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 (edited) Your right using notepad the problem goes away. However if I can just get ShelExec.exe into a varialbe without screwing up the part of the line that works it will work. RunWait ('ShelExec.exe "' & $CmdLine[2] & $file & '"') Edited April 15, 2005 by Mr.Furious
steveR Posted April 15, 2005 Posted April 15, 2005 (edited) Edit: $cmd1 = "shelexec.exe" $cmd2 = "C:\Program Files\" $cmd3 = "test 1.txt" RunWait ($cmd1 & ' "' & $cmd2 & $cmd3 & '"') Edited April 15, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Mr.Furious Posted April 15, 2005 Author Posted April 15, 2005 (edited) Did that work for you? OPPS forgot to compile before testing!! Thanks a bunch Edited April 16, 2005 by Mr.Furious
steveR Posted April 16, 2005 Posted April 16, 2005 yes, it works for me. I caught your script before it left, but i dont know how to implement it. take some more work AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Mr.Furious Posted April 16, 2005 Author Posted April 16, 2005 (edited) It seems to be working fine just needed that one damn apostrophe' in the right spot! eeeeekSorry thought the script was gonna complicate things.Format OpenAll.exe "program.exe" "myfiles\" "*.jpg"Here is the script:$search = FileFindFirstFile($CmdLine[2] & $CmdLine[3]) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files matched " & $CmdLine[3] & " in the " & $CmdLine[2] & " folder.") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($file) ; Skip directories If StringInStr($attrib, "D") Then ContinueLoop RunWait ($CmdLine[1] & ' "' & $CmdLine[2] & $file & '"') WEnd ; Close the search handle FileClose($search)yes, it works for me.I caught your script before it left, but i dont know how to implement it. take some more work<{POST_SNAPBACK}> Edited April 16, 2005 by Mr.Furious
steveR Posted April 16, 2005 Posted April 16, 2005 Glad ya got it working AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
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