(See also: Various simple rename presets -> Make Safe Name)
Hi,
i am a webdeveloper and get often files from my clients to link on websites. The filename has often special characters , which are not websafe like: äöüßáàâ...
The following button uses a vbscript to convert the selected filenames to a websafe format (a-z0-9-_). I hope, you like it.
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>Secure Rename</label>
<tip>Websafe rename of selected files</tip>
<icon1>#format</icon1>
<function type="normal">
<instruction>@nodeselect </instruction>
<instruction>RENAME TO "*" </instruction>
<instruction />
<instruction>@script vbscript </instruction>
<instruction>Option Explicit </instruction>
<instruction />
<instruction>Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, strNewName) </instruction>
<instruction />
<instruction>Dim strAllowed</instruction>
<instruction>Dim tmpFile</instruction>
<instruction>Dim iLen</instruction>
<instruction>Dim i</instruction>
<instruction>Dim strChar</instruction>
<instruction />
<instruction>strAllowed = "abcdefghijklmnopqrstuvwxyz0123456789."</instruction>
<instruction>strNewName = Trim(LCase(strNewName))</instruction>
<instruction />
<instruction>strNewName = Replace(strNewName, "ä", "ae")</instruction>
<instruction>strNewName = Replace(strNewName, "á", "a")</instruction>
<instruction>strNewName = Replace(strNewName, "à", "a")</instruction>
<instruction>strNewName = Replace(strNewName, "â", "a")</instruction>
<instruction>strNewName = Replace(strNewName, "é", "e")</instruction>
<instruction>strNewName = Replace(strNewName, "è", "e")</instruction>
<instruction>strNewName = Replace(strNewName, "ê", "e")</instruction>
<instruction>strNewName = Replace(strNewName, "ö", "oe")</instruction>
<instruction>strNewName = Replace(strNewName, "ó", "o")</instruction>
<instruction>strNewName = Replace(strNewName, "ò", "o")</instruction>
<instruction>strNewName = Replace(strNewName, "ô", "o")</instruction>
<instruction>strNewName = Replace(strNewName, "í", "i")</instruction>
<instruction>strNewName = Replace(strNewName, "ì", "i")</instruction>
<instruction>strNewName = Replace(strNewName, "î", "i")</instruction>
<instruction>strNewName = Replace(strNewName, "ü", "ue")</instruction>
<instruction>strNewName = Replace(strNewName, "ú", "u")</instruction>
<instruction>strNewName = Replace(strNewName, "ù", "u")</instruction>
<instruction>strNewName = Replace(strNewName, "û", "u")</instruction>
<instruction>strNewName = Replace(strNewName, "ß", "ss")</instruction>
<instruction />
<instruction />
<instruction>iLen = len(strNewName)</instruction>
<instruction />
<instruction>for i = 1 to iLen</instruction>
<instruction> strChar = mid(strNewName, i, 1)</instruction>
<instruction> if instr(strAllowed, strChar) > 0 then </instruction>
<instruction> tmpFile = tmpFile & strChar </instruction>
<instruction> elseif right(tmpFile, 1) <> "_" then</instruction>
<instruction> tmpFile = tmpFile & "_"</instruction>
<instruction> end if</instruction>
<instruction>next</instruction>
<instruction />
<instruction>if left(tmpFile, 1) = "_" then</instruction>
<instruction> tmpFile = right(tmpFile, len(tmpFile) - 1)</instruction>
<instruction>end if</instruction>
<instruction />
<instruction>strNewName = Replace(tmpFile, "_.", ".")</instruction>
<instruction>End Function</instruction>
</function>
</button>
Feel free to change the script for your purpose.