make simple files names


I’m mking mp3’s from my hole cd collection and I have file names problems.

I didn’t notice the problem before having already ripped many cd’s :-(. Now most of this is corrected (from grip, for example), but I still have many old files.

These files include many diacritics characters, from freeddb and track name, like éàè’, blanks… This makes it very difficult to make a html page, for example or simply copying them to fat32 for sharing

I seek for a simple bash script that only remove all what is not [az], or replace them by “-”? Better rename could be nice, but not necessary. Looks like the krename “transclusion”, but this one only looks at accents, not apostrophes

I have also many folders and subfolders. I’m pretty used to bash, but not with sed :frowning:


You could feed the filenames through *tr *(see man tr) in something like:

tr 'âáàëéè' 'aaaeee'

but then longer, containing all the characters you want to change.
And that inside a loop that offers the filenames in OFNAME:

   echo "${OFNAME}" | tr 'âáàëéè' 'aaaeee' | read NFNAME
   mv ${OFNAME} ${NFNAME}

Be sure to test if NFNAME does not allready exists because several OFNAMEs could result in the same NFNAME.


yes, thanks. However thinking of any case is pretty hard. I’m concerned by the notice that tr don’t work with multibytes chars, what about utf8?

does the negation work? something like tr ![a-z] -] made on basename could be what I look for

I look also on some sort of sed -e “s/^a-z]/-/g”)

I yet have to try all this, but I was wondering if somebody didn’t already do the job, this problem being pretty common :slight_smile:


well option -c…

It is not too difficult to test this. Instead of the *mv *statement you do an *echo *and you can see what a *mv *will do. You can play with it until you are satisfied and then change *echo *to *mv *for the big bang.

Coming back to your original problem. I do not quite see your web-page problem. When you see that in all phases you work with UTF8 it works perfectly within HTML. I have web pages where parts are input via an HTML form. I type there all sorts of diacritics (as I did in my earlier post) and they show as intended (as the above post is rendered as intended).

Pearl Scrit to read the directories, extract the headers and build filename… There couldnt be a better example to show perl’s utility than this one.