How do I get rid of empty folder tree stubs?

I sync a folder tree /*/*/data/abcd/*/*.* with this .stignore on an Android device with recive-only folder:

!*/abcd/*
*

the source is a send-and-receive folder on a Windows computer that is synced with another Android device with no exclusions. The destination is the Android device with the mentioned receive-only folder.

As expected this results in syncing only trees to the receive-only folder if they contain a folder abcd

But if a tree is deleted on the source there remains remains an empty tree /*/*/data on the destination. Adding (?d) to .stignore (?d)!*/abcd/* doesn’t change the behavior. I also tried it with (?d)!*/data/abcd/*.

How do I get rid of the empty folder tree stubs?

Syncthing won’t delete those directories as it’s not tracking them, because they’re ignored. I don’t think there’s a way to get Syncthing to do that currently.

I would need to experiment with the specific patterns myself to be 100% sure, but I think you could try playing around with the same type of hackery as shown in these two threads:

Thank you very much! Though I don’t understand it fully this seems to work in my case. At least I didn’t find any empty folders any more and I hope that it did not delete to many. :crossed_fingers:

!*/data/abcd/*
(?d)*/*/

Why no set the root of your receive-only folder to abcd instead of data? Then no need of ignore pattern around abcd nor ignore everything else (*).

Only usual (?d)** to remove directories with remaining “OS generated files” as stated in the doc.

Keep in mind also that (?d) doesn’t mean delete for cleanup, only “delete if it’s in the way when anyway deleting the parent directory for some reason”.

The root is not data but two levels below. There are many folders addressed by \*\*\. I was wrong when I posted that there was too much deleted. I missed files in the source folder. But because the Android device has only a receive only folder it can not have deleted files in the source folder. So the posted ignore pattern works in this case with a receive only folder on one end.

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