Created
March 9, 2021 13:30
-
-
Save mttbernardini/51ac57240a02901fb87cb5ed64781b5a to your computer and use it in GitHub Desktop.
Files downloaded from BeeP have url-encoded names, this script fixes names recursively after archives are extracted
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
#!/usr/bin/env python3 | |
import urllib.parse | |
import html | |
import os | |
def fix_names(folder): | |
for f in os.listdir(folder): | |
if os.path.isdir(f): | |
fix_names(f) | |
else: | |
newname = html.unescape(urllib.parse.unquote(f)).replace('+', ' ') | |
os.rename(os.path.join(folder, f), os.path.join(folder, newname)) | |
fix_names(".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment