2016-12-08 17:15:56 +00:00
|
|
|
from sys import argv
|
|
|
|
from os import rename
|
|
|
|
from unidecode import unidecode
|
|
|
|
|
|
|
|
|
2016-12-14 15:45:12 +00:00
|
|
|
# whitespaces will be replaced
|
|
|
|
# dots are ok
|
|
|
|
# do not ruin previous work
|
|
|
|
# dashes are ok
|
|
|
|
whitelist = [' ', '.', '_', '-']
|
|
|
|
|
2016-12-08 17:15:56 +00:00
|
|
|
for file in argv[1:]:
|
|
|
|
rename(file,
|
|
|
|
unidecode
|
|
|
|
(
|
|
|
|
''.join(ch for ch in file
|
|
|
|
if ch.isalnum()
|
2016-12-14 15:45:12 +00:00
|
|
|
or ch in whitelist)
|
2016-12-08 17:15:56 +00:00
|
|
|
)
|
2016-12-11 09:18:19 +00:00
|
|
|
.replace(' ', '_'))
|