Skip to content

Instantly share code, notes, and snippets.

@gdvalle
Created June 23, 2019 16:14
Show Gist options
  • Save gdvalle/cc798c70cc364a05748addf6221a5bec to your computer and use it in GitHub Desktop.
Save gdvalle/cc798c70cc364a05748addf6221a5bec to your computer and use it in GitHub Desktop.
Delete extracted mkv files alongside rar parts.
#!/usr/bin/env python3
import os
import sys
assert sys.version_info[:2] >= (3, 6), "Requires Python 3.6+"
def walk_dir(directory):
for root, dirs, files in os.walk(directory):
mkvs = []
has_rars = None
for fname in files:
if fname.endswith(".r02"):
has_rars = True
if fname.endswith(".mkv"):
mkvs.append(fname)
if has_rars is True and mkvs:
for mkv in mkvs:
path = os.path.join(root, mkv)
print(path)
return 0
if __name__ == "__main__":
sys.exit(walk_dir(os.path.curdir))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment