Skip to content

Instantly share code, notes, and snippets.

@mttbernardini
Created March 9, 2021 13:30
Show Gist options
  • Save mttbernardini/51ac57240a02901fb87cb5ed64781b5a to your computer and use it in GitHub Desktop.
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
#!/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