Delete-empty-src-dirs and exclusions

Hi!

I ran the an rclone move with both -min-age 7d and --delete-empty-src-dirs (dry run). From the log files, it appears that rclone will delete the empty source directories if they have only excluded files (I guess the same way the delete-excluded flag will delete exclusions).

Is this intended behaviour? Is there an alternative command for to only delete empty source directories if it's actually empty (and not just empty because of exclusions)?

Hope this makes sense!

Thanks.

I think your confusion here comes from how filters work in general.
They work on both sides (source and destination).

So for example, if you rclone sync --max-size 10M
Then rclone will completely ignore any larger files on both ends. It won't try to transfer them from the source - but it will also not try to update or delete superfluous files on the destination.

If your goal is to clean up empty directories in general, you might want to use this:
rclone rmdirs /path/to/location
This will remove directories but it can not remove any non-empty folders - so the result is deletion of all empty folders. A nice way to clean up.

If you want to make sure the main folder is never deleted if it runs empty, add the --leave-root flag.
https://rclone.org/commands/rclone_rmdirs/

I'm not 100% sure I understand what you are saying here, but are you saying rclone deleted directories that weren't empty in the source? That would be bad! It might be that rclone attempted to delete directories that weren't empty but it shouldn't have succeeded - the logs should have looked like this

2019/12/04 10:12:33 DEBUG : excluded: Removing directory
2019/12/04 10:12:33 DEBUG : excluded: Failed to Rmdir: remove /tmp/src/excluded: directory not empty

Yes - according to my logs, it appears that it does try to delete the folders that have excluded files. However, I have only done this with --dry-run, so I did not get the "directory not empty" error message - guess it's a non-issue if it doesn't actually delete the folders!

Thanks for your help.

1 Like

Aha, that explains it then :slight_smile:

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