How to sync only top level directories?

This does not work as it also includes the contents of the top level directories:

!/*
*

I don’t want the content of the top level directories. (except where I cherry pick it)

In your patterns, !/* unignores everything, so the following * does basically nothing.

You need something like this:

/*/
2 Likes

This I don’t understand. According to the documentation:

  • Asterisk (*) matches zero or more characters in a filename, but does not match the directory separator. te*ne matches telephone, subdir/telephone but not tele/phone.

  • A pattern beginning with / matches in the root of the synced folder only. /foo matches foo but not subdir/foo.

Therefore, I would expect /* to match only top level files and directories. If I were to use * or /**, I would expect these to match everything.

For syncing only top level files and directories, do you suggest .stignore to be as follows?

!/*/
*

Maybe important to note: I am using Syncthing-Fork on Android.

No, you need just /*/ and nothing else. This will sync only the contents of the folder root, including files and folders, but will ignore everything inside the folders.

In this case, all of these are basically the same. This is because once you ignore a folder, then everything inside it also gets ignored.

1 Like

Thank you, but I don’t understand it. The documentation states:

Say, if I have:

/a
/a/foo.txt
/a/bar.txt
/b
/b/foo.txt
/c
/foo.txt

Then I would expect /*/ to match:

  • The contents of /a:

    /a/foo.txt
    /a/bar.txt
    
  • The contents of /b:

    /b/foo.txt
    

But not /c and not /foo.txt. According to my understanding, what gets synced would be:

/a/foo.txt
/a/bar.txt
/b/foo.txt

This is not what I want. Instead I want to sync only the first level files and directories:

/a
/b
/c
/foo.txt

Which brings me back to this, i.e. the inverse:

But you said, this it not needed.

Honestly, I’m not really sure where the confusion is coming from, but using /*/ will get you precisely the above. On the other hand, your inverted patterns will do exactly the opposite (i.e. sync everything inside the folders, but ignore the folders themselves, and everything else in the root path).

At this point, I would suggest simply experimenting with different patterns using a temporary folder (e.g. share a dummy folder between two devices, add ignore patterns to it on one side, add some files and see what syncs; if you’re not satisfied, delete everything and start from scratch).

1 Like

It comes from me confusing including and excluding, LOL.

Thanks again, all works fine.

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