Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Do you know any smart script to rename files for web format?
(replace all non ASCII characters, spaces, transliterate unicode chars, change case etc.)


my ójf ćżpd - ąąv - hźóż HŹŃÓKŁFU.jpg



I've been playing with rename command, but there is always some new character which my regex does not support. I'm sure there is already a good tool for this task.

share|improve this question
up vote 1 down vote accepted

Can you use Python? This little script:

import urllib
import unicodedata
print urllib.quote_plus(unicodedata.normalize(NFKD', u'my ójf ćżpd - ąąv - hźóż ŹŃÓKŁFU.jpg').encode('ascii','ignore')).replace('+','_')

Produces your requested output of:


This creates an output that is all ASCII and escapes ASCII characters not allowable in URLs. If that does what you are after it shouldn't take much to turn it into the script you need.

share|improve this answer
I have ever used Python before :) Looks promising, but how to recursive iterate the files in the directory? – takeshin Jul 9 '10 at 20:23
import os os.listdir(.) returns a list containing all the files in the directory – Tom O'Connor Jul 9 '10 at 20:31… This works. Instead of appending the files to a list, you'll run the translation code above and then perform the rename from old to new – bk. Jul 9 '10 at 20:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.