Click to See Complete Forum and Search --> : need help for a script to cleaning filename


Davno
10-12-2008, 11:57 AM
Hi
I would like an exemple for a script to clean a bunch of filename in a directory. An exemple that i could build on (modify that exemple script for my purpose).
The problem is that i have a bunch of files mostly .wav, .flac and .mp3s that have weird characters in their filename ( , $ ect...) and audio conversion scripts have problems with that. I have a script to remove or replace blankspace but i don,t know how to remove weird characters.
Exemple changing:
Beethoven , symphony#9.MP3 to Beethoven-symphonyNo9.mp3

In this exemple characters like , and # was changed to No or could just be removed, blankspace were removed and the extension was changed to lower case.
Something to start with, Thanks :D

Calipso
10-12-2008, 02:27 PM
/tmp$ ls
file#4.txt

/tmp$ ls|while read line;do mv $line $(ls $line|sed s/#/No/);done

/tmp$ ls
fileNo4.txt

This should do the trick nicely.

Davno
10-14-2008, 03:01 AM
Thank You
I added that line to an existing script that remove blank space and also i added a line for removing other caracters like " , "
Now the wma2mp3 script run nice. :)