• 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: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?


  • Subject: Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?
  • From: Nick Hearn <email@hidden>
  • Date: Mon, 24 Sep 2007 14:37:13 +0100

***Before acting on this email or opening any attachment you are advised to read the disclaimer at the end of this email***
************************************

Hi there,

Someone, I think it may have been Kai, once wrote this script for me for removing items from the sidebar.
It generates a list of the items in the sidebar and allows you to select which ones you'd like removing.

Regards,

Nick


on chooseItems from theList under prmpt
tell application (path to frontmost application as Unicode text)
return (choose from list theList with prompt prmpt with multiple selections allowed)
end tell
end chooseItems

set computerName to computer name of (system info)
set desktopName to displayed name of (info for (path to desktop))
set networkName to displayed name of (info for alias "Network:")
set userName to displayed name of (info for (path to current user folder))

tell application "Finder"
if ((count each Finder window) is 0) then make new Finder window
end tell

tell application "System Events"
tell application process "Finder"
set frontmost to true
tell list 1 of scroll area 1 of splitter group 1 of window 1



set sidePanelNames to name of UI elements



set itemsToDelete to my (chooseItems from sidePanelNames under "Choose which side panel items to delete:")
if (itemsToDelete is false) then error number -128


repeat with i from 1 to (count itemsToDelete)
set thisItem to item i of itemsToDelete


--select UI element thisItem


perform action "AXShowMenu" of UI element thisItem
if (thisItem is computerName) then
key code {125, 125, 125, 125, 125, 49}
else if (thisItem is networkName) or (thisItem is userName) then
key code {125, 125, 125, 125, 125, 49}
else if (thisItem is desktopName) then
key code {125, 125, 125, 125, 125, 125, 125, 125, 49}
else
key code {125, 125, 125, 125, 125, 125, 49}
end if
delay 0.5 -- Lengthen if necessary.
end repeat
end tell
end tell
end tell





On 24 Sep 2007, at 13:38, Peter Schwenk wrote:

On Sep 23, 2007, at 11:15 PM, Michelle Steiner wrote:

On Sep 23, 2007, at 7:52 PM, Mark J. Reed wrote:

It may help your Googling to know that the "sidebar" is officially
called the "toolbar" (and was originally above the main content rather
than to the side, in fact...).

The toolbar is above the main content of the window; it contains tools for manipulating the window and its contents.

The sidebar is to the left side of the main content of the window; it contains files, folders, and volumes.


I did mean the sidebar (at least that's what it's called in the Finder Preferences tab of the same name).  Let me change my question, since I now know that there's a plist file for the sidebar items, ~/Library/Preferences/com.apple.sidebarlists.plist.  It seems that each entry has three bits of info associated with them, the name of the item, a strangely-encode alias for the item and a strangely-encoded alias for the icon.  Here's what one entry looks like:

<dict>
<key>Alias</key>
<data>
AAAAAAEwAAIAAQZTeXN0ZW0AAAAAAAAAAAAAAAAAAAAA
AAAAAADBPTwjSCsAAAAE6zsHRGVza3RvcAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAATrRr5TV58AAAAAAAAAAP//
//8AAAkgAAAAAAAAAAAAAAAAAAAABXBldGVyAAAQAAgA
AME9dGMAAAARAAgAAL5Tne8AAAABAAgABOs7AABr2AAC
ABpTeXN0ZW06VXNlcnM6cGV0ZXI6RGVza3RvcAAOABAA
BwBEAGUAcwBrAHQAbwBwAA8ADgAGAFMAeQBzAHQAZQBt
ABIAE1VzZXJzL3BldGVyL0Rlc2t0b3AAABMAAS8AABUA
AgAM//8AAA==
</data>
<key>Icon</key>
<data>
SW1nUgAAABwAAAAAU1lTTAAAABAAAAAAZGVzaw==
</data>
<key>Name</key>
<string>Desktop</string>
</dict>

Does anyone have any clues about how the Icon and Alias are encoded?  Once I find that out, I should be able to script the direct manipulation of the plist file to get the effect I need.  Anyone have experience with this?  Thanks in advance!

--
- Peter Schwenk
- CITA-3, Systems Administrator
- Mathematical Sciences
- University of Delaware
- (302) 831-0437
- schwenk _at_ math _dot_ udel _dot_ edu
- http://www.math.udel.edu/~schwenk





**********************************************************************
Communisis plc - registered no: 2916113 is a limited company registered in England and Wales and whose registered office is at Wakefield Road, Leeds, LS10 1DU.

Please Note: This e mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy (s) of the Communisis group in general.

Confidentiality: This e-mail and the contents of any attachments are intended for the named recipient(s) only and may be confidential. If you have received this e-mail and its contents in error you must take no action based on them, nor must you copy or show them to anyone. Please reply to this e-mail and highlight the error.

Warning: Although this e-mail and any attachments have been scanned for viruses, Communisis cannot guarantee that they are virus free. The Communisis group therefore accepts no responsibility for any loss or damage caused by transmission of this e-mail.
**********************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
 _______________________________________________
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: 
 >Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar? (From: Peter Schwenk <email@hidden>)
 >Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar? (From: "Mark J. Reed" <email@hidden>)
 >Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar? (From: Michelle Steiner <email@hidden>)
 >Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar? (From: Peter Schwenk <email@hidden>)

  • Prev by Date: Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?
  • Next by Date: Re: Creating complex HTML messages in mail via AppleScript
  • Previous by thread: Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?
  • Next by thread: Re: Is it possible to Applescript the deletion and addition of items from a Finder window's sidebar?
  • Index(es):
    • Date
    • Thread