mass files with illlegal names in linux

Windows are notorious for having files that are named with illegal characters like ?, & spacing…etc. To mass rename them, remember to use quotations in the mv command. eg

for i in *; do mv "$i" newfile_"$i"; done;

It took me along time to figure out that the error lies in the mv command and not the filenames… I was trying all sorts of backslash tricks with sed and couldn’t get the desired result.

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.