Welcome, guest | Sign In | My Account | Store | Cart

The script converts any accented characters in filenames to their ASCII equivalents. e.g.:

Example:

â > a
ä > a
à > a
á > a
é > e
í > i
ó > o
ú > u
ñ > n
ü > u
...

Before-and-after example:

01_Antonín_Dvořák_Allegro.mp3   >>>  01_Antonin_Dvorak_Allegro.mp3

Usage:

Running the script without arguments will rename all files in the current folder. 
!!!WARNING!!! ***No*** backups are created.
Python, 22 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
# convert unicode filenames to pure ascii

import os
import sys
import glob
import unicodedata 

EXT = u'*.*'

def remove_accents(s): 
    nkfd_form = unicodedata.normalize('NFKD', s) 
    return u''.join([c for c in nkfd_form if not unicodedata.combining(c)])

for fname in glob.glob(EXT):
    new_fname = remove_accents(fname)
    if new_fname != fname:
        try:
            print 'renaming non-ascii filename to', new_fname
            os.rename(fname, new_fname)
        except Exception as e:
            print e