Exclude Files/Folders from Sierra iCloud Sync

macOS Sierra offers the possibility to sync the Documents and Desktop folders to iCloud Drive.

(You can enable this in System Preferences > iCloud > iCloud Drive > Options… > Desktop & Documents Folders)

Basically this can be a nice thing, but sometimes you just want to exclude certain files/folders.

Unlike as with Time Machine or CrashPlan backups, where you can exclude items by setting an extended attribute[1], there is — to my knowledge — no such attribute that would allow you to exclude items from the iCloud sync.

The only way — afaik — to exclude items from iCloud sync is:

  • Put the files in a folder named tmp
  • Append the suffix .tmp or .nosync to a file or folder

Well, this is better than nothing, but, in case of a file, it “kills” the real extension of the file, and hence causes problems.

Today I found out, by accident, that you can use the .nosync suffix also as infix, and it still works:.

So, instead of…


…you can also name it…


This is way better, because the .pdf extension remains intact this way and the file is recognized as pdf by your programs and the Finder.

(BTW, this does not work with .tmp.)

So, here’s a little macro that allows you to quickly mark a file/folder as excluded from iCloud sync:

What the macro does…

…is very simple:

  • If the Finder-selected item has an extension, it will insert the .nosync as infix between basename and extension
  • If the item has no extension (e.g. like most folders), then the .nosync will be appended as suffix

Works also with multiple selections.


  • If a file has two extensions (typically .tar.xz, .tar.gz, etc.) the .nosync will be placed in-between

One could change that behavior, so that the .nosync gets inserted before the first dot, but this would conflict with filenames that have dots in the basename.
I often have dots in the basename, e.g. mydoc.1.1.7-de.pdf, so I prefer the current solution.


  • Since I found that possibility just a couple of hours ago, the macro is not well tested. So please use it carefully and report back any bugs.
  • If you know of any better way to exclude files from iCloud sync (e.g. via extended attribute), please let me know.

Exclude from iCloud Sync.kmmacros (3.8 KB)

[1] com.apple.metadata:com_apple_backup_excludeItem
Edit: I have just posted another macro for that.


This is my original bash version of the macro. You can use it for example as LaunchBar action or as standalone script:



for ARG in "$@"; do
  ext="$([[ "$pathTail" = *.* ]] && echo ".${pathTail##*.}" || echo '')"
  mv "$ARG" "$outPath"
1 Like