script to replace filenames which is giving me some problems