[wellylug] Getting rid of illegal characters in filenames

andrej at paradise.net.nz andrej at paradise.net.nz
Tue Nov 23 16:25:32 NZDT 2004


Quoting jumbophut <jumbophut at gmail.com>:
> mv $i $(echo $i | tr '*$%' 'xyz'); 

> HOWEVER, there is, as I mentioned, a risk. Any change you make risks
> overwriting an existing file. e.g. you have my%file. If you change
> it to myzfile, it might overwrite an already existing myzfile.
> 
> I'm not sure of an easy way to solve this, short of checking for the
> existence of a pre-existing file and changing the replacement char
> (potentially repeatedly if you keep getting matches with existing
> files).
mv --backup t $i $(echo $i | tr '*$%' 'xyz'); 




More information about the wellylug mailing list