Retain file icon when using online storage

I have several scripts in my toolbar in DT3; I have given those scripts their own icons by - in Finder - doing “Get Info” from the context menu, marking the default icon for the file in the top left corner of the Info window and pasting an image in place.

When I transfer those scripts to a second Mac via a folder in iCloud Drive (automatically, using Hazel; but the same thing happens when I do this manually) they still appear to have the icon on the source device; but on all other devices I have the “naked” file without its icon. The same happens if I transfer via OneDrive, but not if I use AirDrop. So it seems the at least both iCloud Drive and OneDrive strip any icon placed as described above. I’ve tried and failed to find more information about this behaviour.

The result of this is that on my MacBook (the device I am copying to) the scripts in the toolbar have no individual icon, but instead all look the same.

Does anybody have any clever ideas?

Thinking out loud here…: can I use a script in the toolbar to simply call a different script? Then the scripts for the toolbar would never change or be updated, and would retain their icons. And the scripts which were called could be updated as and when, and wouldn’t need icons.

Looks like this is what I’d need…: run script ("/Users/<username>/whereever/ascript.scpt" as POSIX file)

Yes it’s possible to call a script from another script but what’s the point in this case?

The basic script (“call other script”) would never need to be changed/updated, and so wouldn’t require syncing across devices, thus wouldn’t lose its icon and would thus remain identifiable in the toolbar. The complex script which it calls could be updated as and when, synced across devices using Hazel and wouldn’t require an icon (which would get lost in the syncing process).

So, for anybody else coming across this problem: yes, that is the solution :wink:

@Blanc unfortunately there doesn’t seem to be a simple “real” solution (if it would work at all).

  • Icons are stored in a file’s extended attribute

  • With iCloud there’s no way of preserving (and I didn’t find a sync provider that preserves it):

One major type of xattr appears always to be stripped across iCloud: This is the modern xattr equivalent of the Mac’s traditional ‘resource fork’, and appears invariably to be stripped even if its name is suffixed with #S.

(Which extended attributes does iCloud preserve, and which get stripped? – The Eclectic Light Company)

Possible solutions, not tested:

macOS File Sharing

File Sharing does preserve

When copying files across networks, provided that both file systems support xattrs (or know how to handle them) and the protocol used is good (SMB and AFP, for instance), then all xattrs should be transferred faithfully. That’s the case when using file sharing in macOS, and it even works nicely over AirDrop.

(Which extended attributes does iCloud preserve, and which get stripped? – The Eclectic Light Company)

  • Maybe this could work:

    • Replace the Toolbar folder with a symlink on the “main” mac and share the actual Toolbar folder.
    • On each other mac replace the Toolbar folder with a symlink to the shared folder.

Downside, I think: You can only edit on one mac, all others have only read access. However, I never used File Sharing so I might be wrong.


This article seems to be quite old Making Resource-Fork-Aware Backups with rsync on Mac OS X.
I guess an option that preserves extended attributes is meanwhile built in, check the rsync man page.

1 Like

Dear Pete, thank you so much for looking into this for me and coming back with such detail! I had searched myself, but not used clever words like attribute or xattr; in the day, icons just used to be icons :see_no_evil: So you’ve expanded my knowledge :slight_smile:

The solution I came up with (not syncing the scripts in the Toolbar folder at all, and only placing single-line scripts calling scripts in a different - synced - folder in the Toolbar) works perfectly for me, so I haven’t looked into symlinking. Only being able to edit on one Mac would be quite a downside - I’m not very good at scripting and like to play with ideas as and when they come to me - all other things permitting, that is :slight_smile:

Thanks again - I enjoy learning and your input in this forum is always appreciated; thank you for sharing your spare time with others in this fashion.

1 Like

Umm… ZIP.

If you ZIP the file and transfer it, the custom icon is easily and successfully retained. :slight_smile:

Sure, but I can’t automate that :slight_smile:

Why would you need to automate it if this is a one-off or rarely occurring situation?

I wouldn’t. But it isn’t. I like to tweak my scripts all the time, making them better of course. But as I said, the problem is solved by having a script which doesn’t ever need to be changed - and therefore keeps its icon - referring to a script which can be changed willy-nilly and doesn’t need an icon, because it isn’t itself represented in the toolbar :slight_smile: