9

Let's say that I want to sync a folder with unison, but I want to sync only .jpg files.

How I could do that?

2 Answers 2

8

You need to add the following lines to your profile:

ignore = Name ?*
ignorenot = Name *.jpg
1
  • 5
    ignore = Name ?* did not work with me, replaced with ignore = Name {,.}*{.*} Commented May 1, 2012 at 7:31
0

Eight years later ... the accepted doesn't properly ignore files with no period, or dotfiles.

And any pattern (say, Regex ^((?!.jpg).)*$) that does matche these will also gobble directories that might have .jpg as a child. (See "Unison starts detecting updates..." under Ignoring Paths in the manual.)

The only way I've found is to let the sync proceed with those extra files included, and then use

find "$DEST" --type f ! -iname "*.jpg" -delete
find "$DEST" --type d -empty -delete

to kill them, and then clean up the empty directories. (In my case, I actually did

find "$DEST" --type d -empty ! -name ".stfolder" -delete

to preserve a SyncThing marker directory--don't ask.)

A potentially bad consequence of this is copying lots of extra data for a short time--in my case, some 3.5GB moves from one partition to another, and then is promptly deleted.

You must log in to answer this question.

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