In the below script - if I copy and paste the contents of the shell script echo to the the terminal and precede it with ‘cp’ it works flawlessly - however the actual shell script that is supposed to cp - says that the file or directory doesn’t exist?? what gives??
set FolderNameString to "PersonalDocuments"
set FileNameString to "ThisFileTest.docx"
set u_path to quoted form of "/Users/MyName/Library/Mobile\\ Documents/com\\~apple\\~CloudDocs/"
set u_dest to quoted form of "/Users/MyName/Google\\ Drive/"
tell application "Terminal"
set a to do shell script "echo " & u_path & quoted form of FolderNameString & "/" & quoted form of FileNameString & " " & u_dest & quoted form of FolderNameString
display dialog a
do shell script "cp " & u_path & quoted form of FolderNameString & "/" & quoted form of FileNameString & " " & u_dest & quoted form of FolderNameString
Any help would be greatly appreciated!!! Thanks !!!
My understanding is that you wrongly use quoted form.
It’s useful to apply it to a complete pathname, but it’s wrong to apply it separately to path components.
quoted form of (posixfolder & “/” & posixfilename) is correct.
quoted form of posixfolder & “/” & quoted form of posixfilename is wrong.
Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) lundi 13 fÃ©vrier 2017 11:28:44
Both are correct. Quoted form is a state and not something that indicates the beginning or the end of an string. A single quote toggles between substitution modes in the shell.
hello’ 'world is the same as ‘hello world’ in the shell. The space requires quotation and if you quote only the space or entire string doesn’t really matter.
UPDATE: Remove the escape characters and use only quoted form instead.
set u_path to quoted form of "/Users/MyName/Library/Mobile Documents/com~apple~CloudDocs/"
set u_dest to quoted form of "/Users/MyName/Google Drive/"
DJ Bazzie Wazzie,
You are my savior.
By removing the escaped characters in the u_path and u_dest files it worked!!!