Inserting characters at certain position?

@steve:

Yes, I tested it once again and they are all working fine now.
Thank you!

This has been a fun exercise for me. I had done some VB scripting over the past few years but up until now I had done very little scripting in Opus. I just finished the following button script code (many thanks to Leo for the link I needed to figure out the dialog box thing) and it seems to do what abr had asked for originally. To use it copy all of the code in the box below, then with Opus in customize mode, right click over a toolbar and choose PASTE.

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Insert Text</label> <tip>Insert text a set number of characters in from left side of selected file names</tip> <icon1>#newcommand</icon1> <function type="normal"> <instruction>Rename TO=&quot;{DlgStringS|Enter number of characters from left, comma, and text to insert|2,Text to Insert}&quot;</instruction> <instruction>@nodeselect </instruction> <instruction /> <instruction>@script vbscript</instruction> <instruction>option explicit</instruction> <instruction /> <instruction>Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )</instruction> <instruction /> <instruction> Dim intComPos &apos; Location of the leftmost comma in dialog box entry</instruction> <instruction> Dim strText &apos; Extracted Text from dialog box entry</instruction> <instruction> Dim strCount &apos; Extracted number (of places from left) from dialog box entry</instruction> <instruction /> <instruction> &apos; Find the leftmost comma</instruction> <instruction> intComPos = InStr(strNewName,&quot;,&quot;)</instruction> <instruction> if intComPos &gt; 0 then</instruction> <instruction> strCount = Trim(Left(strNewName, intComPos-1))</instruction> <instruction> strText = Right(strNewName,Len(strNewName)-intComPos)</instruction> <instruction> end if</instruction> <instruction /> <instruction> Dim Dots</instruction> <instruction> Dots = &quot;&quot; </instruction> <instruction /> <instruction> Dim I</instruction> <instruction> I = 0</instruction> <instruction> While I &lt; CInt(strCount)</instruction> <instruction> Dots = Dots &amp; &quot;.&quot;</instruction> <instruction> I = I+1</instruction> <instruction> Wend</instruction> <instruction> Dots = &quot;(&quot; &amp; Dots &amp; &quot;)&quot;</instruction> <instruction> </instruction> <instruction> Dim regex</instruction> <instruction> &apos; Create a RegExp object</instruction> <instruction> Set regex = new RegExp</instruction> <instruction> regex.Pattern = Dots &amp; &quot;(.*)&quot;</instruction> <instruction> strNewName = regex.Replace(strFileName, &quot;$1&quot; &amp; strText &amp; &quot;$2&quot;) &apos;</instruction> <instruction>End Function </instruction> </function> </button>

JohnZeman, thank you very much. So we have different solutions now & also it wasn´t originally for me, i think i can use it sometimes. :laughing:

@JohnZeman:

You've done a very good job!

I was very pleased with the solution of "JOERG765" already but yours is much more comfortable using just one Dialog-Box.

Would it be possible to create a Button that deletes a given Number of Characters at certain Position with your Script?

For instance simply inserting "3,5" in the Box would delete 5 Characters behind the 3rd Position.

Now that I've got some fundamentals down about using VBScript in Opus I should be able to do that without much problem. :slight_smile:

I'll post something later on about it.

kundal I've added the new script to the Buttons & Toolbars section

http://resource.dopus.com/viewtopic.php?f=18&t=12373

@JohnZeman:

Many Thanks for your excellently working Buttons and your very fast reply!