Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@deeuu
Last active August 8, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeuu/32a1ab4dd912d66f2b607b20bafa1a9f to your computer and use it in GitHub Desktop.
Save deeuu/32a1ab4dd912d66f2b607b20bafa1a9f to your computer and use it in GitHub Desktop.
xonsh script to list all directories on a remote that do not contain files (but may contain folders), via rclone
import re
rclone_remote_path = 'drive:/temp'
dirs = re.findall('\d+:\d+:\d+\ +-1\ +(.*?)\n',
$(rclone lsd -R @(rclone_remote_path)))
file_dirs = re.findall('\d+\ +(.*\/?(?=\/))',
$(rclone ls @(rclone_remote_path)))
print('~~ Directories with no files ~~')
empty_dirs = set(dirs) - set(file_dirs)
for _ in empty_dirs:
print(_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment