Last active
June 8, 2021 17:23
-
-
Save deibit/183611962061af42bfe3b834cb4521c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
import rarfile | |
cwd = os.getcwd() | |
# Unrar all rar files | |
files = ['pdf','epub','azw3'] | |
for rar in os.listdir(cwd): | |
if rar.endswith('.rar') and rarfile.is_rarfile(rar): | |
current = rarfile.RarFile(rar) | |
for name in current.namelist(): | |
if any([name.endswith(ext) for ext in files]): | |
print("extracting ... %s" % name) | |
current.extract(name) | |
print("removing ... %s" % rar) | |
os.remove(rar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment