I don't really like the the older "Make Web-safe" rename script, because it removes all diacritic signs (like "ĘÓĄŚŁŻŹŃęóąśłżźćń") instead of replacing them with web safe characters. I've created a JScript which first replaces diacritics with their equivalents and then it finally does whitelist replacing, in case anything was missed. It also uses dashes instead of underscores. Of course you should add replacements from your language (this one does full polish replacement)
Any remarks appreciated.
Download
Script code
Use the download above if you just want to use the script. The code is reproduced below to help people browsing for scripting techniques on the forum.
This script is also on GitHub: Directory Opus JScript slugify/web-safe rename
function Rename::GetNewName2 ( strFileName, strFilePath, _fIsFolder, strOldName, strNewName ){
r = strFileName;
r = r.toLowerCase();
r = r.replace(new RegExp("[àáâãäåą]", 'g'),"a");
r = r.replace(new RegExp("[æ]", 'g'),"ae");
r = r.replace(new RegExp("[çčçć]", 'g'),"c");
r = r.replace(new RegExp("[èéěêëę]", 'g'),"e");
r = r.replace(new RegExp("[ìíîï]", 'g'),"i");
r = r.replace(new RegExp("[ñń]", 'g'),"n");
r = r.replace(new RegExp("[òóôõöó]", 'g'),"o");
r = r.replace(new RegExp("[œ]", 'g'),"oe");
r = r.replace(new RegExp("[ùūúûü]", 'g'),"u");
r = r.replace(new RegExp("[ł]", 'g'),"l");
r = r.replace(new RegExp("[ð]", 'g'),"d");
r = r.replace(new RegExp("[ś]", 'g'),"s");
r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
r = r.replace(new RegExp("[żź]", 'g'),"z");
r = r.replace(new RegExp("[É]", 'g'),"E");
r = r.replace(new RegExp("[Ö]", 'g'),"O");
r = r.replace(new RegExp("[Á]", 'g'),"A");
//removing all characters except:
r = r.replace(/[^-_a-zA-Z0-9.,\s]+/ig, '');
// replacing all spaces with dashes
r = r.replace(/\s/gi, "-");
return r;
}
I've used these two sources: