To add an item to the Command+K connect to server favorites:
/usr/bin/sfltool add-item -n "foobar" com.apple.LSSharedFileList.FavoriteServers "afp://foo.bar"
I have to ask. What's ~/.sidebarshortcuts?
Is there a way to delete all server favourites?
Same as @jamiegalbreath, I have server favorites that I need to remove somehow (in my case, the Server URL has a .local suffix that I need to remove).
I can create the new entry in the favorites list by using the commands above, but I end up with 2 entries in the list (1 with the .local address, which doesn't work with Sierra for some reason.... and one with the updated URL).
Does anyone know how to remove an existing server from the list (or even just clear the list)?
EDIT: I've determined that running an "sfltool clear" will wipe all of the shared file lists on logout (it looks like it deletes the contents of the "com.apple.sharedfilelists" folder).
I haven't figured out how to target just one list (like "Favorite Servers" for example).
Also, because it seems to require a logout to take effect, I can't add the new server after running the clear command (the behaviour I'm seeing is that if I try, it retains the bad server entry).
I've tried "killall cfprefsd" (is this even a thing anymore?), but it doesn't help.
sfltool
.....10.13..... :(
which sfltool in 10.13 returns /usr/bin/sfltool @bpavlov
@djdavetrouble I know the tool is still there. But it's been crippled. It doesn't have the same functionality that it previously had the last time I checked.
Yep. It's been gutted.
10.12
Usage: sfltool restore|add-item|save-lists|test|archive|enable-modern|dump-server-state|clear|disable-modern|dump-storage|list-info [options]
10.13
Usage: sfltool archive|list-info|list [options]
Hello,
Radr away!
rdar://35722438
jkb
Apple! bring back sfltool in 10.13 !!!!
Apple...

"Apologies, we do not plan to add back the feature. You will need to write a tool that does what’s needed."
-Apple
Had an app that mapped network drives and wrote Favorites icons to finder using slftool. Worked great in 10.12, in 10.13 I noticed when I ran the app it would create a .sfl2 file. So I'd see:
com.apple.LSSharedFileList.FavoriteItems.sfl
com.apple.LSSharedFileList.FavoriteItems.sfl2
Unfortunate that it appears I can't use the app anymore. Did anyone come up with a workaround for this?
I don't have a workaround, but a 'work with [Apple] for future state'...
Rather than asking for a binary solution, I would ask for an MDM payload solution. The settings in question are ultimately stored in plists. This makes them ripe for configuration profile management.
For 10.13 I switched to using FinderSidebarEditor
This uses the "deprecated" but still working LSSharedFileList commands and seems to be the only way to do sidebar tasks on 10.13. I'd say a a configuration profile is less than ideal, two of the items we regularly add to the sidebar are programmatically defined not static (network home and network shared space), profiles also wouldn't help for linking to locations which could be changed by the user (a OneDrive or OwnCloud folder), really sfltool was ideal and needed an improvement to delete entries.
@dsavageED thanks, I will look into that. I haven't worked with Python before (have been focused on AppleScript and Bash) so it'll probably be a down-the-road kind of thing.
@el2493 I am by no means that familiar with python ( I can read and code it a bit), but to leverage that script all you really need is:
#!/bin/bash
# Assuming FinderSidebarEditor.py script is stored in /usr/local/python you can call the function inside a bash script
python - <<EOF
import sys
sys.path.append('/usr/local/python') # Custom location script is installed to
from FinderSidebarEditor import FinderSidebar # Import the module
sidebar = FinderSidebar() # Create a Finder sidebar instance to act on.
sidebar.add("$path") # Add '$path' favorite to sidebar
EOF
Thanks, that's very helpful!
@dsavageED I'm going to keep looking into this, but since you had the previous information I was wondering what the format of "$path" should be? I tried /volumes/[share name] (and the favorite showed as a "?" and wouldn't open) before looking at the python code and finding it was going to be a little more complicated than that.
Trying to make sense of:
def add(self, to_add, uri="file://localhost"):
"""
Append item to sidebar list items.
Args:
to_add (str): Path to item to append to sidebar list.
Keyword Args:
uri (str): URI of server where item resides if not on localhost.
"""
if uri.startswith("afp") or uri.startswith("smb"):
path = "%s%s" % (uri, to_add)
to_add = mount_share(path)
item = NSURL.alloc().initFileURLWithPath_(to_add)
LSSharedFileListInsertItemURL(self.sflRef, kLSSharedFileListItemBeforeFirst, None, None, item, None, None)
self.synchronize()
self.update()
So would the path need to be defined as "%s%s" % (file://localhost, /volumes/[share name])? Or does it need the actual path of the drive/folder and not the volumes information? I also tried different combinations of "%s%s" % ([the path]) and wasn't having any luck.
Figured it out...the path of the volume was /Volumes/share_name$ and the "$" was messing things up. Changed to /Volumes/share_name$ and it worked.
Using FinderSidebarEditor, I have two questions:
- How are current home folders expressed? ~/Desktop isn't working for me. I get a ? mark.
- How are spaces in paths for shares handled?
"afp://name:password@server/Data" works
"afp://name:password@server/Old Data" does not work. Neither does "afp://name:password@server/Old Data"
EDIT: Regarding the home folder:
Using:
#!/usr/bin/python
CurrentUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
from FinderSidebarEditor import FinderSidebar # Import the module
sidebar = FinderSidebar() # Create a Finder sidebar instance to act on.
sidebar.remove("All My Files") # Remove 'All My Files' favorite from sidebar
sidebar.remove("iCloud") # Remove 'iCloud' favorite from sidebar
sidebar.add("/Library") # Add '/Library' favorite to sidebar
sidebar.add("/Applications") # Add '/Library' favorite to sidebar
sidebar.add("/Users/$CurrentUser/Desktop") # Add '/Library' favorite to sidebar
sidebar.add("/Users/$CurrentUser/Downloads") # Add '/Library' favorite to sidebar
^
I get the following error (TextWrangler points to the last character in the variable line).
File "/usr/local/bin/Test2.py", line 3
CurrentUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
@gskibum mysides seems to work a little easier than FinderSidebarEditor, despite it not being updated in a few years, but outside of that, I'm pretty sure your error is related to the fact that python variables from commands don't use the backtick syntax like in bash.
I don't really know python, but I made the following modification to the beginning of your script and it seems to at least get the correct logged in user's name. Not sure if the rest of it will work since I didn't really try it.
#!/usr/bin/python
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
import sys
CurrentUser = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [CurrentUser,""][CurrentUser in [u"loginwindow", None, u""]]
The main issue is that you had the backtick syntax, plus, you're using a python one liner within a python script, but it was only ever a one liner because of needing to embed it into bash scripts. Since your entire script is python, I broke out the individual commands. Also, it's possible that to use a path to mysides that includes that CurrentUser variable, something else in the script needs to be changed. I don't think you just string them together like that in python.
Again, I really don't know python, so this might be a horrible way to do it. I just don't know what I don't know, so, there you go :-)
Some Python pros over at Slack got me working with this:
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]
username = [username, ""][username in [u"loginwindow", None, u""]]
Then call it like this:
sidebar.add("/Users/%s/Pictures" % username)
How are ya'll adding AirDrop back to the Finder Sidebar?
I'm trying this command with mysides but getting nowhere:
$mysides add domain-AirDrop "nwnode://domain-AirDrop"
killall cfprefsd