Le 2015/12/09 à 21:53, Deivy Petrescu < email@hidden> a écrit :
On Dec 9, 2015, at 10:19 , Yvan KOENIG <email@hidden> wrote:
Thanks
but it’s a nightmare because I use the original syntax in numerous scripts since several years. I’m really surprised to see that such a simple syntax is now failing.
Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) mercredi 9 décembre 2015 16:19:38
Now you understand what I felt yesterday… 😉 Anyway, I agree with Axel’s reply. AS sometimes needs a get or an intermediary step. As Axel suggested moving the « set dest to quoted form …” outside the tell bloc or using Script Editor instead of me would work.
Moving the instruction out of the tell block is what I did with the handler quotePOSIXit.
I tried to use tell application « Script Editor » and was forced to use an « ugly » syntax.
--set sourcefolder to (path to desktop as text) & "formoosmahna:" as alias --set keyName to "staff_01"
set sourceFolder to choose folder set keyName to text returned of (display dialog "Type a folder name" default answer "Staff_01")
tell application "System Events" set theSubFolders to folders of sourceFolder repeat with aSubfolder in theSubFolders set itsFiles to (files of aSubfolder whose visible is true) if itsFiles is not {} then set movableFiles to {} repeat with aFile in itsFiles if name of aFile contains keyName then set end of movableFiles to contents of aFile end repeat if movableFiles is not {} then set dest to (path of aSubfolder as text) & keyName & ":" if not (exists folder dest) then make new folder at end of aSubfolder with properties {name:keyName} end if -- set posixDest to my quotePOSIXit(dest) -- finally my best choice tell application "Script Editor" set posixDest to quoted form of POSIX path of dest # Here it works end tell repeat with aFile in movableFiles log (get class of aFile) --> (*file*) -- set qSource to my quotePOSIXit(path of aFile) -- finally my best choice tell application "Script Editor" set qSource to quoted form of (get POSIX path of file (path of aFile)) # I don't understand why but, aFile which is a file isn't one for POSIX path set qSource to quoted form of (get POSIX path of aFile) --> error "Il est impossible de rendre file \"SSD 500:Users:ME:Desktop:formoosmahna:sub1:1 Amazing (feat. Laughton Kora)staff_01.wav\" of application \"System Events\" dans le type attendu." number -1700 from file "SSD 500:Users:ME:Desktop:formoosmahna:sub1:1 Amazing (feat. Laughton Kora)staff_01.wav" end tell do shell script "mv " & qSource & space & posixDest end repeat
end if end if end repeat end tell # System Events
on quotePOSIXit(aPath) # really useful for the POSIX part return quoted form of POSIX path of aPath end quotePOSIXit
It works but from my point of view it’s really ugly and I will stay using the quotePOSIXit handler.
Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) mercredi 9 décembre 2015 22:23:09
|