Rép: Ghost Comments
Rép: Ghost Comments
- Subject: Rép: Ghost Comments
- From: KOENIG Yvan <email@hidden>
- Date: Sat, 18 Feb 2012 19:50:10 +0100
I apologizes, I posted my answer to Luther, not to the forum.
Le 18 févr. 2012 à 00:46, Luther Fuller a écrit : While working on a script this afternoon, I noticed something that shouldn't happen. So, I wrote this quick test script (in 10.6.8) to discover what was happening ...
set deskAlias to (path to desktop) tell application "Finder" if exists folder "TEST" of deskAlias then (folder "TEST" of deskAlias) as alias as text tell application "System Events" to delete disk item the result end if delay 1 set newFolder to (make new folder at deskAlias with properties {name:"TEST"}) as alias delay 1 get comment of newFolder display dialog the result buttons {"OK"} default button 1 end tell
After the first run, you will have a folder "TEST" on your desktop. Get Info for this folder and enter some text in the comment field. Close Get Info.
Now run this script again, and again, and ...
Every time it runs, it displays the text you entered in the comment field. Yet the folder and presumably its comment have been deleted on each run.
The fix is to use this: set newFolder to (make new folder at deskAlias with properties {name:"TEST", comment:""}) as alias
Anyone have an explanation? It seems that the Finder doesn't receive the info "the item is deleted so discard the comment". Here I treat the problem a different way.
set deskAlias to (path to desktop) tell application "Finder" if exists folder "TEST" of deskAlias then (* folder "TEST" of deskAlias delete result tell application "System Events" to delete disk item (result as text) *) tell application "System Events" to delete disk item ((delete (get folder "TEST" of deskAlias)) as text) end if set newFolder to (make new folder at deskAlias with properties {name:"TEST"}) as alias get comment of newFolder display dialog the result buttons {"OK"} default button 1 end tell
I commented the expanded code and keep as active the single instruction.
The Finder delete the folder so it discard the comment and System Events delete the trashed object.
Yvan KOENIG (VALLAURIS, France) samedi 18 février 2012 13:31:06
|
_______________________________________________
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