gcue

quotes issue

9 posts in this topic

hello

i am using this line to copy files

$command = ' /AutoIt3ExecuteLine "Exit(FileCopy(''' & $master_sorted_array[$x][0] & ''', ''' & $target_dir & '''))"'

RunWait(@AutoItExe & $command)

however i am coming across a problem when the file path contains a single quote

any idea how to get around that?

thank you in advance!

Share this post


Link to post
Share on other sites



Use Consolewrite($command&@crlf) and you see what's wrong in scite console.

Share this post


Link to post
Share on other sites

it is definitely the single quote found in file paths bc that's where i get a parsing error

Share this post


Link to post
Share on other sites

i am also trying to FileRecycle some files same issue of course.. here are the output messages...

consolewrite

Quote

/AutoIt3ExecuteLine "Exit(FileRecycle('C:\Users\Smith\Desktop\New folder1\m's pics\20151229_160630 - Copy.jpg'))"

error

Quote

Exit(FileRecycle('C:\Users\Smith\Desktop\New folder1\m's pics\20151229_160630 - Copy.jpg'))

Exit(FileRecycle('C:\Users\Smith\Desktop\New folder1\m's pics^ERROR

Error: Unable to parse line.

 

Share this post


Link to post
Share on other sites

mmm 2000+ posts and still looking for the basics. ;)

Exit(FileRecycle("C:\Users\Smith\Desktop\New folder1\m's pics\20151229_160630 - Copy.jpg"))

 

1 hour ago, gcue said:

it is definitely the single quote found in file paths bc that's where i get a parsing error

Show the content of the variable so I can see what it contains.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hello. This should work.

 

Local $command = ' /AutoIt3ExecuteLine "Exit(FileCopy(' & _Quoted($master_sorted_array[$x][0]) & ',' & _Quoted($target_dir ) & '))"'

RunWait(@AutoItExe & $command)

Func _Quoted($sString)
    Return '""' & $sString & '""'
EndFunc   ;==>_Quoted

Saludos

Share this post


Link to post
Share on other sites
14 minutes ago, Danyfirex said:

Hello. This should work.

 

Local $command = ' /AutoIt3ExecuteLine "Exit(FileCopy(' & _Quoted($master_sorted_array[$x][0]) & ',' & _Quoted($target_dir ) & '))"'

RunWait(@AutoItExe & $command)

Func _Quoted($sString)
    Return '""' & $sString & '""'
EndFunc   ;==>_Quoted

Saludos

genius idea!  

works great!

muchas gracias!

Share this post


Link to post
Share on other sites

You're wellcome(De nada) ;)

 

Saludos

1 person likes this

Share this post


Link to post
Share on other sites
22 minutes ago, Jos said:

mmm 2000+ posts and still looking for the basics. ;)

Exit(FileRecycle("C:\Users\Smith\Desktop\New folder1\m's pics\20151229_160630 - Copy.jpg"))

 

Show the content of the variable so I can see what it contains.

Jos

i dont think its basic at all.  there's a mix and possibility of single and double quotes and i wanted to make sure i was able to capture the possibilities.

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