Command: RenameEx (extended Rename command)

RenameEx - a script-addin for extended "Rename" functionality.

Features summary:

Main command line switches:

  • NUMBER Add numbering to items (this wraps the native Rename NUMBER command)
    • Options: = <startindex> Default is 1

    • Switches:

      • REMOVENUM Try to remove existing numbering from affected items
      • PAD The number of digits in padding, default is "auto"
      • PADWITH The characters used for padding, default is "0" (only applies to totals)
      • BY Increment when renaming items, default is 1
      • PATTERN Defaults to (.*?)((?:[^A-z0-9]*|\\s*)?\\D?\\d+.*?)?($|\\..*)
      • TO Defaults to {stem} {num}{ext}

      Following additional vars are available (also the native ones with FILEINFO):

      • {num} The ongoing number
      • {stem} Item stem or basename (without extension)
      • {ext} The items extension (including .)
      • {total} Total item count
      • {totalfiles} Total file count
      • {totaldirs} Total dir count
      • {totalsel} Selected item count
      • {totalselfiles} Selected file count
      • {totalseldirs} Selected dir count
    • Examples:

      • Add basic numbering in front of extension, remove existing numbering at first
        RenameEx NUMBER REMOVENUM

      • Add numbering and ".. of x" in front of extension, pad numbers to 3-digits
        RenameEx NUMBER PAD=3 TO="{stem}-{num} of {totalsel}{ext}"

      • Do not add numbering, just add "of x" in front of extension, padding as required
        RenameEx NUMBER PAD TO="{stem} of {totalsel}{ext}"

      • Enter a new name for all selected items and append numbering and ".. of x"
        RenameEx NUMBER PAD TO="{dlgstring|New filename:|{file|noext}} - {num} of {totalsel}{ext}"

Global switches/options:

  • PATTERN Works like the regular PATTERN of the rename command
  • FROM Works like the regular FROM of the rename command
  • TO Works like the regular TO of the rename command
  • FILEINFO Works like the regular FILEINFO of the rename command
  • NODESELECT Do not deselect selected items
  • PT Switches and options to PassThrough to the native Rename command
  • XLOG Level of output, defaults to normal, which means important information only
    • Options: = off,xit,err,inf,warn,,trace,dump

Installation:
To install the command, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts.

Trouble-Shooting:
In case you encounter errors, add XLOG=dump to your commandline or raise the global log level in the script config.

Then re-do what failed and post the result (output) right here! o)

cya,
tb

Download:

  • v0.3.1 - 2025-09-09
    Command.Generic_RenameEx.js.txt (54.4 KB)
    // - use FSMagic v0.61
    // - reorder change log
    // - import fix from RenameFromClipboard v0.3.1: fix FSMagic.getBasename() returning "" for files without extension
    // - import fix from RenameFromClipboard v0.3.1: add placeholder %item.new_name_stem%

  • v0.3 / 2015-10
    Command.Generic_RenameEx.js.txt (51.8 KB)
    //- new option "RECURSE", recursive rename for all items (native rename does not support this for folders)

  • v0.2 - 2015-10
    //- new option "FROMCLIP", renders RenameFromClipboard command obsolete
    //- passing of pad-with changed to PAD="width=0"
    //- passing of pad-size changed to PAD="size=2"

  • v0.1.1 / 2015-05-24 - unwanted output and padding error fixes:
    Command.Generic_RenameEx.js.txt (22.5 KB)

  • v0.1 / 2015.05.24 - initial version:
    Command.Generic_RenameEx.js.txt (22.3 KB)

The command.. RenameEx NUMBER PAD TO="{stem} of {totalsel}{ext}"

..fails when run against selected files in Downloads as shown below..


If I copy the files to a normal folder - e.g. C:\Test - and run the same command it works properly.

Regards, AB

Updated to v0.1.1:

  • unwanted output fixed
  • padding error fixed

Thanks aussie! o))
I guess it was not necessarily related to that folder, but to the number of items within.

Will you be adding button to these or Commandline only?

Thank you

Thanks for your interest! o)

This command will be overhauled at some time, as I'm not yet satisfied on how it works internally. Until then, I guess I won't provide a button with defaults. The other thing is, finding defaults for a rename-button is probably not easy, as everyone has his own preferences on how to re-name things, but maybe yes. Maybe there should be a button to download nonetheless! o)

Hello,

Sorry if this is a stupid question but I am a little new at this. I tried out this script also but I was not successful.

dopo asked
"Will you be adding button to these or Commandline only?"

Does this mean that the above RenameEx script can only be run through a Commandline meaning you have to type the commands out in the command line field each time you want to apply it to files?

I tried both making it a tool button as well as trying to enter it into a command line field but I wasn't able to get it to work.

Seems that in your response, you may still be working on this one.
I am new to applying user based scripts, some I can get to work and others I have not.
I don't specifically need this script it is more the question if I am doing something wrong.
I have come across a couple of other hiccups in other scripts but I will put them in the appropriate threads.

Thank You

Buttons can make use of commands or scripts (which again can use commands). This is a command and there are some example command lines given, which you can put into a button if you wish, but you don't need to, you can run them in a DO commandline as well. So this thread just does not provide a button with presets which run this command. You can make your own button quite easily from the example command lines given above, it's just some copy and paste work.

Sorry being new to some of this stuff, I read into this one incorrectly on how to set it up and I got a little confused.
I now have gotten this one to work, testing it a little it now makes more sense to me, I see what you mean about making buttons, there are so many things this script can do that each user will have a different button depending on their individual needs.

Wow, how the heck are you doing all of this, I wish I could script like this.
Next on my list is to test your SelectEx, not sure if it will be something that I will use as of yet but it is funny, many of these things it takes a while get used to using them and they don't seem needed and then before you know it you use them so much you can't imagine not having them.

Thank You for the script and your response.

Im still getting an error with the new script installed:

9/6/2025 7:31 AM Main process started.
9/6/2025 7:31 AM Command.Generic_RenameEx.js: Error at line 63, position 39
9/6/2025 7:31 AM Command.Generic_RenameEx.js: Object doesn't support this property or method (0x800a01b6)
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Loaded successfully.
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: ColumnCache():
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: CacheID: ScriptDetails
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Version: 0.6
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Enabled: false
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Persist: true
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Expire : 604800000 (7.00 days, 168.00 hours, 10080.00 mins, 604800.00 secs)
9/6/2025 7:31 AM Command.Generic_ScriptWizard.js.txt: Columns:
9/6/2025 7:38 AM Command.Generic_RenameEx.js.txt: Error at line 63, position 39
9/6/2025 7:38 AM Command.Generic_RenameEx.js.txt: Object doesn't support this property or method (0x800a01b6)

What do you mean with "still".. ?! There has been no post about an error, no post from you and no post for 9 years either. o)

Maybe try the RenameEx version I uploaded now.. it is slightly newer, I don't get errors when the script initializes.

EDIT: Hu? Don't you remove the *.txt extension from the script files before copying a script into the scripts folder of DO? I also see two RenameEx outputs in your log snippet, one with *.txt extension and one without, please have one only.

i apologize, I misread the error above mine, and thought it was the same error as mine. That was my mistake.

let me look at what you've mentioned.

Even after removing the .txt, I get the same error

I don't believe you have to remove the .txt, I've never had to in the past. I installed your new version 3 and it appears to accept that without any errors. Thank you for looking at the error, appreciate you taking the time.

Yep V3 works. No errors on loading of DO. Thank you again.

Thanks for the feedback, you're welcome! o)