Re: Where is Trash Folder(?)?
Re: Where is Trash Folder(?)?
- Subject: Re: Where is Trash Folder(?)?
- From: Yvan KOENIG <email@hidden>
- Date: Sat, 26 Sep 2015 20:38:28 +0200
Le 2015/09/26 à 20:19, Robert Poland < email@hidden> a écrit :
On Sep 26, 2015, at 11:41:AM, Yvan KOENIG <email@hidden> wrote:
Le 2015/09/26 à 19:34, Robert Poland <email@hidden> a écrit :
Hi,
I’m trying to create a script, below, that I can add to a Keyboard Maestro shortcut. This script works with normal folders but “Trash” doesn’t seem to have a home.
Any thoughts/suggestions?
(* openTrashContainer - 9/26/15 - By R L Poland *)
tell application "Finder" activate set TrashFolder to (path to Trash folder) set windowList to name of Finder windows as text # display dialog windowList if windowList contains "Trash" then close window "Trash" else open folder TrashFolder end if end tell
TIA,
(1) path to is not a Finder command but a Standard Additions one.
(2) It seems that you failed top look in Standard Additions dictionary.
There is no "path to trash folder" command, just a "path to trash" one.
Taking care of that, it's easy to build a script which behave flawlessly.
set TrashFolder to (path to trash) tell application "Finder" activate set windowList to name of Finder windows as text # display dialog windowList if windowList contains "Trash" then close window "Trash" else open folder TrashFolder end if end tell
Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) samedi 26 septembre 2015 19:41:13
I keep getting the error "Result: error "Finder got an error: Can’t make alias \"Macintosh HD:Users:rpoland:.Trash:\" into type folder." number -1700 from alias "Macintosh HD:Users:rpoland:.Trash:” to folder“ Robert Poland Fort Collins, CO
You didn't ran the code which I post because it doesn't try to coerce an alias into a folder. May you retry after copying the exact code which I posted ?
Below is a version usable worldwide. Yours assume that the trash is named Trash which is not true everywhere.
set trash_loc to my getLocalizedString("Finder", "AXICON6")
set TrashFolder to path to trash tell application "Finder" activate set windowList to name of Finder windows as text log windowList # display dialog windowList if windowList contains trash_loc then close window trash_loc else open folder TrashFolder end if end tell
on getLocalizedString(a, x) return localized string x in bundle path to application a end getLocalizedString
Yvan KOENIG (VALLAURIS, France) samedi 26 septembre 2015 20:36:41
|
_______________________________________________
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