Ignore only folders in root

I would like to sync only files within a folder, not folders.

For example: Root is c:\folderA\

  • c:\folderA\file.docx is a file in root = sync OK
  • c:\folderA\folderX.xlsx is a file in root= sync OK
  • c:\folderA\folder1\file.jpg is a file in a folder = no sync
  • c:\folderA\folder2\ is a folder in root = no sync

How can I archive this?

I already tried:

  • /* → ends sync of all files and folders
  • */ → results in empty folders on synced nodes
  • */* → results in empty folders on synced nodes
  • */** → results in empty folders on synced nodes

You’ll need /*/.

1 Like

Thank you @imsodin. Unfortunately /*/ also results in empty folders on synced nodes.

  • /* → ends sync of all files and folders
  • */ → results in empty folders on synced nodes
  • */* → results in empty folders on synced nodes
  • */** → results in empty folders on synced nodes
  • /*/ → results in empty folders on synced nodes

See below, I “mis-thought”.

I don’t think this is really possible, because Syncthing doesn’t distinguish between files and directories when it comes to ignore patterns. The only imperfect solution that I can think about is something like

!*.*
*

yet this will only work if all your files have extensions (which is quite likely, as we’re talking about Windows here, but still).

Right, I was mistaken, the slash at the end does mean ignore everything below, but not the directory itself - thanks for the clarification @tomasz86

Hello @tomasz86

!*.*
*

…sounds logical, but my Syncthing installation seems to be no friend of logics. If I set up that ignore pattern, files and folders are synced, like there is no ignore pattern at all.

I’ve tested those patterns locally, and they should sync only folders that contain files (with extensions). Have you check what happens in a new pair of folders? Please keep in mind that the patterns will only apply to newly created content, i.e. they won’t delete already existing empty folders.

Thank you for the advice. For every test, I create a new folder and a new txt-file, both with the same timestamp (YYYYMMDDHHMMSS) as name in root. Then I copy an other test file in that folder. By doing so, I assume I only have “new” folders and files, that are unknown to Syncthing.

Actually folders should not synced - no matter what´s inside.

PS. But you are right - empty folders are not synced… :wink:

If I understand correctly, what you actually want may be

// Ignore everything in subfolders.
/*/
// Don't ignore files with extensions in root folder.
!/*.*
// Ignore everything in root folder.
/

however, as already mentioned, this is quite flaky, as files with no extensions will also be ignored, while folders with a . in them won’t be (e.g. Paint.NET).

Thanks @tomasz86 and @imsodin. That works quite well, even with the mentioned restrictions.

// Ignore everything in subfolders.
/*/
// Don't ignore files with extensions in root folder.
!/*.*
// Ignore everything in root folder.
/
2 Likes

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