~~Title: Rename ~~ The **Rename** internal command can be used to: * Trigger [[:file_operations:renaming_files:inline_rename|inline rename]] mode, letting you quickly edit the name of a file or folder * Display the [[:file_operations:renaming_files|Rename]] dialog, letting you perform wildcard and scripted renames on multiple files at once * Perform automated rename operations * [[:customize:creating_your_own_buttons:embedding_rename_scripts|Embed a rename script]] in a button or hotkey Note that the [[:file_operations:renaming_files:advanced_rename]] dialog lets you automatically create a command line using the user interface - simply configure the dialog as desired and then select **Create function from current settings** from the dropdown **Clipboard** menu at the bottom of the dialog. **Command Arguments:** $$ Argument $$ Type $$ Possible values $$ Description $$ (#)//(no argument)// $$ - $$ - $$ Displays the **[[:file_operations:renaming_files|Rename]]** dialog. The rename operation will be performed on all selected files and folders. The dialog will open in the last mode it was used in (either [[:file_operations:renaming_files:simple_wildcard_rename|simple]] or [[:file_operations:renaming_files:advanced_rename|advanced]]). ``Rename`` $$ ADVANCED $$ /S $$ //(no value)// $$ Displays the Rename dialog in [[:file_operations:renaming_files:advanced_rename|advanced]] mode. ``Rename ADVANCED`` When combined with rename patterns or preset names, the **ADVANCED** argument can be used to ensure the command opens the Rename dialog instead of immediately renaming all selected items. ``Rename ADVANCED PATTERN=* TO=*.bak``\\ ``Rename ADVANCED PRESET="Number Files"`` $$ APPLYNOMATCH $$ /S $$ //(no value)// $$ Turns on the **Apply actions even if pattern doesn't match** option for the rename function. This makes things like the **CASE** argument apply to all filenames, whether they match the old name pattern (given by the **PATTERN** argument) or not. ``Rename PATTERN "*.jpeg" TO "*.jpg" CASE=allwords APPLYNOMATCH`` $$ AUTONUMBER $$ /S $$ //(no value)// $$ Automatically adds an incrementing number to the end of new filenames if they clash with existing files. ``Rename PATTERN "The *" TO * AUTONUMBER`` $$ BY $$ /K/N $$ //// $$ Specifies the increment when renaming files with automatic numbering (using the **NUMBER** option). If not specified the default increment is 1. ``Rename NUMBER BY 2`` $$ CASE $$ /K $$ **upper** $$ Converts filenames to all-upper case. ``Rename CASE=upper`` $$ $$ $$ **lower** $$ Converts filenames to all-lower case. ``Rename CASE=lower NUMBER`` $$ $$ $$ **firstword** $$ Capitalizes the first letter of the filename. ``Rename CASE=firstword`` $$ $$ $$ **allwords** $$ Capitalizes the first letter of each word of the filename. ``Rename CASE=allwords`` $$ $$ $$ **extupper** $$ Converts the filename extension to upper case. ``Rename CASE=extupper`` $$ $$ $$ **extlower** $$ Converts the filename extension to lower case. ``Rename CASE=extlower`` $$ $$ $$ **extignore** $$ Ignores the extension while applying case changes to the filename. Use this in conjunction with one of the other keywords. ``Rename CASE=upper,extignore`` $$ FINDREP $$ /O $$ //(no value)// $$ Enable find-and-replace mode. The **PATTERN** argument must be used to provide the string to find, and the **TO** argument provides the string to replace it with. You can optionally combine this with the **REGEXP** argument. ``Rename FINDREP PATTERN="jones" TO="smith"`` $$ $$ $$ **ext** $$ Makes find-and-replace operate in the filename extension as well as in the stem of the filename. ``Rename FINDREP=ext PATTERN="jpg" TO="jpeg"`` $$ FROM $$ $$ // ...// $$ Renames the files specified on the command line, rather than those selected in the source file display. This argument can accept filenames or [[..:..:wildcard_reference:pattern_matching_syntax|wildcard patterns]]. Remember to enclose each filename in quotes if it contains spaces. ``Rename FROM C:\Spool\*.tmp TO *.temp`` $$ HEADING $$ /O $$ //(no value)// $$ When used with commands which generate a list of items (see [[:customize:creating_your_own_buttons:editing_the_toolbar:dynamic_buttons|dynamic buttons]]), the **HEADING** argument adds a small heading at the start of the list. The heading will be hidden when the list is empty. Headings only happen for commands which potentially generate multiple items at the same level as the button itself. When **HEADING** is used by itself, without specifying a text value, the main button's label text is used for the heading. ``Rename PRESET=!list,favesonly HEADING`` $$ $$ $$ //// $$ You can specify the heading text if you want it to be different to the button's label. ``Rename PRESET=!list HEADING="Rename Presets"`` $$ IGNOREEXT $$ /S $$ //(no value)// $$ Turns on the **Ignore extensions** option for the rename function. Filename extensions won't be affected and don't need to be accounted for in any wildcard patterns. ``Rename PATTERN * TO *_backup IGNOREEXT`` The **Ignore extensions** option is off by default for non-interactive renames, to avoid breaking old buttons. You only need to use the **IGNOREEXT** argument with rename commands which specify everything on the command line and do not open the Rename dialog. The **Ignore extensions** option is on by default for interactive renames which open the dialog. You can turn the option off in the dialog via the separate **NOIGNOREEXT** argument, documented below. $$ INLINE $$ /O $$ //(no value)// $$ Activates [[:file_operations:renaming_files:inline_rename|inline renaming]] on the item in the source file display that currently has focus. ``Rename INLINE`` $$ $$ $$ **all** $$ Automatically selects the entire filename for editing. ``Rename INLINE=all`` $$ $$ $$ **name** $$ Automatically selects the filename's stem (but not the extension). Selects the whole name for a folder. ``Rename INLINE=name`` $$ $$ $$ **endstem** $$ Positions the cursor at the end of the filename's stem (before the extension), but does not automatically select any part of the name. ``Rename INLINE=endstem`` $$ $$ $$ **ext** $$ Automatically selects the filename's extension. Selects the whole name for a folder. ``Rename INLINE=ext`` $$ $$ $$ **home** $$ Positions the cursor at the beginning of the filename. ``Rename INLINE=home`` $$ $$ $$ **end** $$ Positions the cursor at the end of the filename. ``Rename INLINE=end`` $$ $$ $$ **single** $$ If more than one item is selected, the **Rename** dialog will be displayed. Without this, inline rename will begin on the focused item only. ``Rename INLINE=name,single`` $$ MACRO $$ /K $$ $$ Lets you specify a rename [[:file_operations:renaming_files:advanced_rename:rename_actions:rename_macros|macro operation]] string. You can use the macro builder in the Rename dialog to generate these strings and then hardcode them in a command. ``Rename`` MACRO R0-6/L0+Final $$ MATCHCASE $$ /S $$ //(no value)// $$ Makes the rename operation case-sensitive. Patterns and search strings must match the exact case of the filename. ``Rename PATTERN *.jpG TO *.JPG MATCHCASE`` $$ NOFILEINFO $$ /S $$ //(no value)// $$ Disable file information metadata insertion. For example, the string **{mp3title}** would normally insert the title of an MP3 file in the new filename. With **NOFILEINFO** specified, the literal string "{mp3title}" would be inserted in the new filename. ``Rename PATTERN * TO *_{name} NOFILEINFO `` $$ NOIGNOREEXT $$ /S $$ //(no value)// $$ Turns off the **Ignore Extension** option in the Rename dialog when it first opens. You only need to use this argument when opening the Rename dialog for interactive use. ``Rename PATTERN *.JPEG TO *.JPG ADVANCED NOIGNOREEXT`` For non-interactive use of the Rename command, the **Ignore Extension** option is off by default (to avoid breaking old buttons) and can be turned on via the separate **IGNOREEXT** argument, documented above. $$ NOMATCHNOFAIL $$ /S $$ //(no value)// $$ Files which do not match the rename pattern are not 'failed'. This can be useful with multi-line functions which need to do some optional renaming before passing all of the files to additional commands. By default, when **NOMATCHNOFAIL** is not used, if a file does not match the rename pattern then it will be flagged as a failure and skipped by the rest of the function (unless the very next command is another **Rename**, in which case the file gets a second chance). If **NOMATCHNOFAIL** is used then files which do not match the rename pattern are still passed to subsequent commands. ``Rename PATTERN "* Backup.*" TO *.* NOMATCHNOFAIL`` $$ NUMBER $$ /O $$ //(no value)// $$ Automatically number files. Selected files will be numbered in the order they are presented in the file display, so you should make sure the list is sorted as desired before using this command. The number 1 will be assigned to the first selected file, and the number for each subsequent file will be incremented by the value given for the **BY** argument (or by 1 if **BY** is not provided). By default the number is added to the end of the filename, in front of the extension. You can specify a different location for the number by providing the **[#]** marker in the new filename. ``Rename PATTERN * TO [#]* NUMBER`` $$ $$ $$ //// $$ Number files starting with the specified number. Providing a value for NUMBER also lets you zero-pad the assigned number. For example, the value **0010** means to start numbering at 10, and zero-pad to four digits. The **[#]** marker can also be used to specify zero-padding - **[#5]** would zero-pad to five digits. ``Rename NUMBER 00001 BY 2`` If you add a **!** before the number, you can use this argument to specify the default value for the corresponding field in the Rename dialog without actually turning on the sequential numbering option. For example, you may want a default of "01" so you get padding to two digits without having to type the extra "0" every time you turn on the option in the UI. If you make use of that, you should also include the **ADVANCED** argument so the Rename dialog appears, instead of it silently performing a rename operation. ``Rename ADVANCED NUMBER=!01`` $$ PATTERN $$ /K $$ //// $$ Specifies a wildcard pattern that represents the old (original) filename. This argument is used when performing a wildcard rename. The Rename command supports a simple wildcard syntax where one or more asterisks supplied for the **PATTERN** argument can be used to copy parts of the original name to the new name. The **PATTERN** argument is also used in conjunction with **REGEXP** to provide the search pattern for a regular expression rename, and in conjunction with **FINDREP** to provide the search string for a find-and-replace rename. See the section on [[:file_operations:renaming_files|Renaming Files]] for a full discussion of the various renaming modes. ``Rename PATTERN IMGP(.*).jpg TO "Image \1.jpg" REGEXP`` Specifying the **FROM** argument as well will mean the command ignores the current file selection and applies the specified rename on all matching files. Only files matching both the TO and PATTERN arguments would be renamed. ``Rename FROM *.jpg PATTERN IMGP(.*).jpg TO "Image \1.jpg" REGEXP`` If the **PATTERN** and **TO** arguments are both given, the command will normally apply the rename immediately, without prompting for any further interaction; you can add the **ADVANCED** argument to instead display the Rename dialog, with the specified pattern, so that you can preview the operation and make adjustments, or cancel it entirely, as needed. ``Rename ADVANCED PATTERN * TO *.bak`` $$ PRESET $$ /K $$ **findrep** $$ Opens the **Rename** dialog in //Find and Replace// mode. ``Rename PRESET=findrep`` $$ $$ $$ **regexp** $$ Opens the **Rename** dialog in //Regular Expression// mode. ``Rename PRESET=regexp`` $$ $$ $$ **regexpfindrep** $$ Opens the **Rename** dialog in //Regular Expression + Find and Replace// mode. ``Rename PRESET=regexpfindrep`` $$ $$ $$ **last\\ !last** $$ Specifying **PRESET=last** opens the **Rename** dialog showing the settings from the last time the dialog was used. Similar to opening the dialog and clicking the //Last Rename// button. ``Rename PRESET=last`` You can also use **!last** to apply the last rename automatically, without showing the **Rename** dialog first. ``Rename PRESET=!last`` $$ $$ $$ **!list** $$ Displays a generated list of saved rename presets (acts as a [[:customize:creating_your_own_buttons:editing_the_toolbar:dynamic_buttons|dynamic button]]). Selecting a preset from the list will apply that rename operation to the currently selected files and folders. The generated list can be controlled with the addition of the following keywords: * **favesonly**: Only displays presets marked as favorites. * **nofaves**: Only displays presets not marked as favorites. * **nogroup**: Don't not group favorite and non-favorite presets separately. ``Rename PRESET=!list,favesonly`` $$ $$ $$ //// $$ Applies the named saved rename preset to all currently selected files and folders. Rename presets are created through the **[[:file_operations:renaming_files:advanced_rename|Advanced Rename]]** dialog. ``Rename PRESET="Number Files"`` You can add the **ADVANCED** argument to make the dialog open and allow you to make changes, or cancel the operation entirely, before the rename is applied. ``Rename ADVANCED PRESET="Number Files"`` $$ RECURSE $$ /S $$ //(no value)// $$ The rename operation will operate recursively on all files inside selected sub-folders. ``Rename PATTERN *.jpg TO *.jpeg RECURSE`` $$ REGEXP $$ /S $$ //(no value)// $$ Enables regular expression mode. The search pattern must be provided with the **PATTERN** argument, and the replace pattern with the **TO** argument. You can optionally combine this with the **FINDREP** argument. ``Rename PATTERN "(.*) - (.*)\.(.*)" TO "\2 - \1.\3" REGEXP`` $$ RENAMEMATCHING $$ /S $$ //(no value)// $$ Keeps files with the same stem and different extensions together when renumbering. For example, **IMGP1032.JPG** and **IMGP1032.WAV** when renamed would be given the same number. ``Rename NUMBER 0001 RENAMEMATCHING`` $$ SCRIPTARG $$ /K/M $$ //\\ [...]// $$ Used to pass custom field values to a [[:scripting:rename_scripts|rename script]]. ``Rename PRESET MyRename SCRIPTARG my_option:True`` $$ SIMPLE $$ /S $$ //(no value)// $$ Displays the Rename dialog in [[:file_operations:renaming_files:simple_wildcard_rename|simple]] mode. ``Rename SIMPLE`` $$ TO $$ /O $$ //// $$ Specifies the new name of the file to rename. This argument is also used to specify the 'to' pattern when renaming using wildcards or regular expression, and the 'replace' string when renaming in find-and-replace mode. This argument can also be provided without a value when doing a find-and-replace rename - in that case, the search string would be replaced with nothing. ``Rename PATTERN " (Copy)" TO FINDREP`` $$ TYPE $$ /K $$ **files** $$ Force the rename to only operate on files - any selected folders will be ignored. ``Rename PATTERN * TO *.bak TYPE=files`` $$ $$ $$ **dirs** $$ Force the rename to only operate on folders. ``Rename PATTERN * TO Copy_* TYPE=dirs`` $$ WHENEXISTS $$ /K $$ **ask** $$ Controls what happens if the new filename already exists. The default action is to **ask** the user for each existing file. ``Rename PATTERN * TO *.bak WHENEXISTS=ask`` $$ $$ $$ **delete** $$ Performs the rename as requested, deleting the file that already existed. ``Rename PATTERN * TO *.bak WHENEXISTS=delete`` $$ $$ $$ **keep** $$ Performs the rename as requested, renaming the old file that already existed. ``Rename PATTERN * TO *.bak WHENEXISTS=keep`` $$ $$ $$ **rename** $$ Modifies the new name by adding a suffix to make it unique. ``Rename PATTERN * TO *.bak WHENEXISTS=rename`` $$ $$ $$ **skip** $$ Skips any files that already exist, without performing the rename. ``Rename PATTERN * TO *.bak WHENEXISTS=skip``