Created
July 8, 2020 23:59
-
-
Save vesche/79d509c940564e2a178d6b680aa8eae3 to your computer and use it in GitHub Desktop.
Rename3
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
for f in os.listdir('.'): | |
is_file = False | |
if os.path.isfile(f): | |
is_file = True | |
for delimiter in [' ', '.', '_']: | |
f_split = f.split(delimiter) | |
if len(f_split) > 3: | |
break | |
else: | |
continue | |
year = False | |
for i in f_split[::-1]: | |
try: | |
year = int(i) | |
if 1900 < year < 2022: | |
year = str(year) | |
break | |
except: | |
continue | |
if not year: | |
print(f'[!] ERROR: Year not found for {f}') | |
continue | |
title = list() | |
for i in f_split: | |
if i == year: | |
break | |
title.append(i) | |
title = ' '.join(title) | |
quality = str() | |
if '1080' in f: | |
quality = '1080' | |
elif '720' in f: | |
quality = '720' | |
elif '576' in f: | |
quality = '576' | |
elif '480' in f or 'DVDRip' in f: | |
quality = '480' | |
else: | |
quality = '?' | |
print(f'[-] WARN: Quality not found for {f}') | |
if is_file: | |
new_name = f'{title} ({year}) [{quality}]' | |
os.system(f'mkdir "{new_name}"') | |
os.system(f'mv "{f}" "{new_name}"/') | |
else: | |
new_name = f'{title} ({year}) [{quality}]' | |
os.system(f'mv "{f}" "{new_name}"') | |
print(f'[+] {f}\n\t=> {new_name}') | |
print('\nFinalizing...') | |
os.system('chmod 755 -R *') | |
os.system('find . -iname *sample* -exec rm -rf {} \;') | |
os.system('find . -iname *.txt -exec rm -rf {} \;') | |
os.system('find . -iname *.nfo -exec rm -rf {} \;') | |
os.system('find . -iname *.sfv -exec rm -rf {} \;') | |
print('Finished!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment