Rename script for secure iso renaming

Hi,

I would like to rename files to a secure iso format. I've written some time ago a script for a tool called awxrename:

use locale; $file =lc($file);$file =~s/ß/ss/gi; $file =~tr/[ä,á,à,â,é,è,ê,ö,ó,ò,ô,í,ì,î,ü,ú,ù,û]/[a,a,a,a,e,e,e,o,o,o,o,i,i,i,u,u,u,u]/; $file =~s/\W+/_/gi; $file =~s/_+/_/gi; $file =~s/^_//gi; $file =~s/_$//gi;

A webdesigner, I need this often to rename files from clients, ie:
"Tag der offenen Tür.pdf" to "tag_der_offenen_Tur.pdf"

or

"Wießner-Themé Diskurs.pdf" to "wiessner-theme diskurs.pdf"

I am looking for an elegant solution. Can you help me?

thank_you:-)

As a web designer myself I understand your need for this. However I don't understand all the special characters you'll have to convert so I'm just guessing from what you have posted here. To me an elegant solution would be if Opus could do a direct conversion but at the moment I don't think that's possible. The next best solution (in my mind) would be if you could pass the names of the files to an external program to convert them, but again I'm not aware of any such program. Perhaps a renaming script would be a good solution, but I have done very little scripting with the Opus renaming script language, so I'm left with one possible solution. To create two buttons, the first to replace all the special characters that need converting, like this:

@nodeselect Rename PATTERN "ä" TO "a" FINDREP Rename PATTERN "à" TO "a" FINDREP Rename PATTERN "â" TO "a" FINDREP Rename PATTERN "é" TO "e" FINDREP Rename PATTERN "è" TO "e" FINDREP Rename PATTERN "ê" TO "e" FINDREP Rename PATTERN "ö" TO "o" FINDREP Rename PATTERN "ó" TO "o" FINDREP Rename PATTERN "ò" TO "o" FINDREP Rename PATTERN "ô" TO "o" FINDREP Rename PATTERN "í" TO "i" FINDREP Rename PATTERN "ì" TO "i" FINDREP Rename PATTERN "î" TO "i" FINDREP Rename PATTERN "ü" TO "u" FINDREP Rename PATTERN "ú" TO "u" FINDREP Rename PATTERN "ù" TO "u" FINDREP Rename PATTERN "û" TO "u" FINDREP Rename PATTERN "ß" TO "ss" FINDREP

Then create a second button to make the selected files lowercase and without spaces, something like this:

@nodeselect Rename CASE=lower PATTERN " " TO "-" FINDREP

It should be possible to do it all in one button, however I haven't been able to make the combined commands work.

Best done with a rename script:

Rename scripts in JScript, VBScript and PerlScript

OK, i will write it in vbscript and publish it.

Hi Leo,

I made a vbscript-routine for secure renaming. Unfortunatley it works 100% in IE, but not in dopus. The for-next doesn't has any effect.

Any suggestions?

<?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 &quot;*&quot; </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 = &quot;abcdefghijklmnopqrstuvwxyz0123456789.&quot;</instruction> <instruction>strNewName = Trim(LCase(strFileName))</instruction> <instruction /> <instruction>strNewName = Replace(strNewName, &quot;ä&quot;, &quot;ae&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;á&quot;, &quot;a&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;à&quot;, &quot;a&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;â&quot;, &quot;a&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;é&quot;, &quot;e&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;è&quot;, &quot;e&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ê&quot;, &quot;e&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ö&quot;, &quot;oe&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ó&quot;, &quot;o&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ò&quot;, &quot;o&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ô&quot;, &quot;o&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;í&quot;, &quot;i&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ì&quot;, &quot;i&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;î&quot;, &quot;i&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ü&quot;, &quot;ue&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ú&quot;, &quot;u&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ù&quot;, &quot;u&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;û&quot;, &quot;u&quot;)</instruction> <instruction>strNewName = Replace(strNewName, &quot;ß&quot;, &quot;ss&quot;)</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) &gt; 0 then </instruction> <instruction> tmpFile = tmpFile &amp; strChar </instruction> <instruction> elseif right(tmpFile, 1) &lt;&gt; &quot;_&quot; then</instruction> <instruction> tmpFile = tmpFile &amp; &quot;_&quot;</instruction> <instruction> end if</instruction> <instruction>next</instruction> <instruction /> <instruction>if left(tmpFile, 1) = &quot;_&quot; then</instruction> <instruction> tmpFile = right(tmpFile, len(tmpFile) - 1)</instruction> <instruction>end if</instruction> <instruction /> <instruction>Rename_GetNewName = Replace(tmpFile, &quot;_.&quot;, &quot;.&quot;)</instruction> <instruction>End Function</instruction> </function> </button>

Change

strNewName = Trim(LCase(strFileName))to

strNewName = Trim(LCase(strNewName))

And change

Rename_GetNewName = Replace(tmpFile, "_.", ".")to

strNewName = Replace(tmpFile, "_.", ".")

Yessss:-) I published it under the renaming scripts.