How to get the list of folders in the sidebar using AppleScript?

It is okay to get the list of all items too since I will be able to search for them

  • If you just want a list of names of the items in the Sidebar, then it's very easy to get a list of the items in the Sidebar in Finder using UI Scripting and System Events, however it varies a bit based on the OS version. What version of OS X/macOS are you running? – user3439894 Jan 30 '18 at 15:18

You can't. Finder's Sidebar is a location for shortcuts to be easily accessible by the user.

From Apple's Human Interface Design Guidelines:

the sidebar in a Finder window includes a list of frequently accessed locations and tag-based search shortcuts. The user can select one to access its contents or results in the main portion of the window.

Additionally, having a folder list is not practical in this element. Anything more than 2 levels of hierarchy (which is highly plausible in a folder listing) is discouraged. In this instance, Apple states that a column view be used.

In general, refrain from exposing more than two levels of hierarchy within a sidebar. In some cases, a second sidebar may be warranted when a data hierarchy is deeper than two levels. If your app requires the navigation of deeply nested objects, consider implementing a column view.

Bottom line; Apple discourages 3rd party developers from doing this, meaning Apple's Finder is definitely not going to show files like this.

You can put a shortcut to a folder, but you won't get a list of folders.

  • thank you for your answer, what I want to do is get the folders list and compare them to a premade list, because finder wipe them out sometimes when the machine is restarted, I want to compare them if they don't exist I add them, that's the reason, you might have a work around this, thank you – Kamel Labiad Jan 30 '18 at 14:22
  • That's an entirely different question from this one meaning it needs to be a new question (if applicable - it hasn't been asked and answered already). What you want to do is compare a list of files/folders with a known list and this can be done in AppleScript or in Bash (Terminal). Personally, I prefer Terminal. – Allan Jan 30 '18 at 14:25
  • but as you mention before it seems not very possible to get the list of items on the sidebar in first place... – Kamel Labiad Jan 30 '18 at 14:27
  • Just because it can't be in the side bar doesn't mean it can't be in a window. If you do this in programmatically, why not just have the script tell you what's changed? Why write a script that you have to manually search? – Allan Jan 30 '18 at 14:34
  • Yes I would like to, I just could not find how – Kamel Labiad Jan 30 '18 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .