Jump to content

Recommended Posts

Posted

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)
Posted (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 by Mr.Furious
Posted (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 by Mr.Furious
Posted

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.

Posted

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.
Posted

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}>

Posted (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 by Mr.Furious
Posted (edited)

It seems to be working fine just needed that one damn apostrophe' in the right spot! eeeeek

Sorry 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 by Mr.Furious

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
  • Recently Browsing   0 members

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