Last active
August 29, 2015 14:10
-
-
Save Hexcles/7bdb32025c95292e41cf to your computer and use it in GitHub Desktop.
Rename urlencoded (quoted) filenames
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 | |
from sys import argv | |
from os import path, system | |
from urllib.parse import unquote | |
if len(argv) == 1: | |
print("Usage: urldecode.py FILES...") | |
exit | |
for f in argv[1:]: | |
dn = path.dirname(f) | |
if dn == '': | |
dn = '.' | |
fn = path.basename(f) | |
fn = path.splitext(fn) | |
fn = unquote(fn[0]) + fn[1] | |
cmd = "mv -i '%s' '%s'" % (f, dn + '/' + fn) | |
print(cmd) | |
system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment