• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: I made a nightmare
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I made a nightmare


  • Subject: Re: I made a nightmare
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 09 Dec 2015 22:30:25 +0100


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




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >I made a nightmare (From: Yvan KOENIG <email@hidden>)
 >Re: I made a nightmare (From: Yvan KOENIG <email@hidden>)
 >Re: I made a nightmare (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Finder Shows No Windows when Hidden
  • Next by Date: Re: Finder Shows No Windows when Hidden
  • Previous by thread: Re: I made a nightmare
  • Next by thread: Re: I made a nightmare
  • Index(es):
    • Date
    • Thread