--max-depth 1 plus remove no longer existing directories


#1

Hi all,
Anyone know of a clever way to remove no longer existing sub-directories while using ‘–max-depth 1’ ?
Currently I’m thinking of doing a ‘rclone sync --max-depth 1’ followed by listing and comparing the remote and local directories, then deleting the no long existing directories.


#2

Does rclone rmdirs do what you want? That wil remove all the empty directories.


#3

I think this would work:

  1. rclone sync --maxdepth 1 localdir remotedir
  2. get subdirs of remotedir
  3. get subdirs of localdir
  4. find remote subdirs which don’t exist locally (“subdirs of remotedir” - “subdirs of localdir”)
  5. rclone purge “remotedirs not local”