Use ignore patterns to sync only certain files of one folder


(uok) #1

A have a little trouble getting ignore patterns to sync the right files :confused: Syncthing runs on Windows with a folder like this

syncthing
 - prefix-abc1-suffix.jpg
 - prefix-abc2-suffix.jpg
 + folder A
   - prefix-abc1-suffix.jpg
   - prefix-abc2-suffix.jpg
   - prefix-abc1-suffix.mpg
   - prefix-abc2-suffix.mpg
   - prefix-def1-suffix.jpg
   - prefix-def1-suffix.mpg
 + folder B
   - prefix-abc1-suffix.jpg
   - prefix-abc2-suffix.jpg
 + folder C
   - prefix-ghi1-suffix.jpg
   - prefix-jkl2-suffix.jpg

I want to sync all images that match *abc*.jpg but only from folder A no files should be synced from syncthing folder root or any other folders (e.g. folder B, folder C, etc.), even if the match the pattern or have the same images

Thanks! :slight_smile:


Sync only certain files with Ignore Patterns
(Audrius Butkevicius) #2

I think this should work:

!/folder A/*abc*.jpg
!/folder A
*

(uok) #3

Thanks, I tried this - it’s close but not correct

expected

+ folder A
  - prefix-abc1-suffix.jpg
  - prefix-abc2-suffix.jpg

but this is result

+ folder A
  - prefix-abc1-suffix.jpg
  - prefix-abc2-suffix.jpg
  - prefix-abc1-suffix.mpg
  - prefix-abc2-suffix.mpg
  - prefix-def1-suffix.jpg
  - prefix-def1-suffix.mpg

Any ideas?


(Audrius Butkevicius) #4

You might need to add: /folder A/* after or before: !/folder A

but my gut feeling says that the initial version should have worked.


(uok) #5

Working solution

!/folder A/*abc*.jpg
/folder A/*
!/folder A
*

1st line includes wanted files in wanted folder, 2nd line excludes all other files in this folder, 3rd line includes wanted folder itself (otherwise 1st line would not work) 4th line excludes rest

It’s somehow logical but confusing :unamused: and heavy on user’s brain :slight_smile:


.stignore - can't unignore a subfolder of an ignored folder