Include only files and folders?

I want to sync the internal storage of my phone to my pc, but i want to include only specific folders and files and exclude everything else. Also, i want to exclude sub folders from the included folders. This is what i use for ignore patterns:

!Documents/ Documents/PDF/ !Books/ *

It works for syncing only included folders: !Documents/,!Books/, but it doesn’t work for excluded folder: Documents/PDF/

Patterns are matched in order, first match wins. !Documents/ will match before it sees Documents/PDF/.

1 Like

i tried this but it still didn’t work:

Documents/PDF/
!Documents/
!Books/
*

The patterns look correct. Please keep in mind that ignoring files afterwards won’t delete those which have been already synced before adding the patterns, i.e. you need to delete them manually.

3 Likes

Is there option to delete excluded folders that are already synced? Something like --delete-excluded option for rsync.

Not directly, but it can be done. And it is a bit complicated. And first we need to establish some naming conventions in Syncthing lingo:

  • A “directory” is a placeholder in the filesystem. It can for example contain other directories and files.
  • A “folder” is an entity you create in Syncthing. It is typically shared between devices.

Make sure that you have the ignore patterns on the phone, NOT on the PC. That’s the only way I know to get below scheme to work.

  • Remove the folder (but NOT the directory) from Syncthing on the PC.
  • Add it again (and make sure you use the same directory) and set the folder type to “Receive Only".
  • Wait for the scan to finish.
  • Wait for the comparison to take place.
  • When you get the ‘Revert local changes’ button, press it. This will cause the content on the PC to be identical to the non-ignored stuff on the phone.

Each time you have adjusted the ignore pattern, repeat the steps above.

Try it out on a small test directory for which you create a separate Syncthing folder. You don’t want to experiment on “production” data… :slight_smile:

1 Like

There should be a more simple solution for this. I will just delete folders manually.

That is the simple solution, indeed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.