Delete everything except one folder

How do I delete everything in a remote folder except a certain other folder? For example, if I have:

Music/
Music/Pop/...
Music/Jazz/..
Music/Rock/..

And I want to delete everything, but the Rock folder. I've tried this:

rclone --filter="- Pop/" --filter="+ *" delete b2:media/Music

But that that wants to delete everything. Reversing the -/+ on filter results in no operation happening at all.

This should do it - delete everything but the Pop folder

rclone --dry-run --filter="- Pop/**" --filter="+ *" delete b2:media/Music

Use rclone ls with the same params to test out

rclone --filter="- Pop/**" --filter="+ *" ls b2:media/Music

Thanks! That worked.

1 Like

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