Introduction

Altap Salamander: Plugins: Renamer: Introduction

Getting Started with Renamer Plugin

With Renamer plugin you can rename many files and directories (optionally including subdirectories) in a batch using specified rules. You can e.g. search for substrings in names and replace them with something else; insert size, time, and date stamps; insert counters with decimal or hexadecimal base; use regular expressions for sophisticated substitutions and reordering; change case of names and extensions; rename also filenames including full or relative path (move files to another directories); and use manual mode for direct filenames renaming (like in text editor). All planned changes are visible in real-time preview of resulting names. These changes are committed to a disk when you click on the Rename button. Moreover, in case of need, you can revert all performed rename operations using the Undo command.

© 2001-2019 ALTAP. All rights reserved.


Batch Renaming

You can rename many files and directories in a batch using specified rules.

To batch rename:

  1. Select the files and directories you want to rename.
  2. Open the Batch Rename dialog box:
    Menu: Plugins/Renamer/Batch Rename...
    Shortcut key: Ctrl+Shift+R
  3. Specify rules for renaming. See examples below.
  4. Click the Rename button.

Examples

You can find here examples of typical use of the Renamer plugin. Description of all options is in the Batch Rename dialog box.

Using a counter
Adding a prefix to all names
Replacing a word in all names
Removing spaces from all names
Reordering words in names
Using structured name to create directory structure
Moving all files from subdirectories into one directory
Removing only periods that are not surrounded by digits

Using a counter

Lets say we have files P1020652.JPG, P1020653.JPG, and P1020654.JPG. And we want to rename them to House1.jpg, House2.jpg, and House3.jpg.

  1. Select our three files (P1020652.JPG, P1020653.JPG, and P1020654.JPG) in panel.
  2. Open the Batch Rename dialog box.
  3. Go to the New name combo box and type word "House" here.
  4. Click the button next to the New name combo box.
  5. Choose Counter from the context menu. It opens the Add Counter dialog.
  6. Type "1" to the Start at edit box.
  7. Choose the OK button.
  8. Counter has been added. Value in the New name combo box is "House$(Counter:1)".
  9. Go to the New name combo box and add ".jpg" to the end of text.
  10. Now you should see House1.jpg, House2.jpg, and House3.jpg in the Preview listview in the New Name column.
  11. Choose the Rename button.

Adding a prefix to all names

Lets say we have files House1.jpg, House2.jpg, and House3.jpg. And we want to rename them to NewHouse1.jpg, NewHouse2.jpg, and NewHouse3.jpg.

  1. Select our three files in panel.
  2. Open the Batch Rename dialog box.
  3. Go to the New name combo box and type word "New" here.
  4. Click the button next to the New name combo box.
  5. Choose Original Name from the context menu.
  6. Value in the New name combo box is "New$(OriginalName)".
  7. Now you should see NewHouse1.jpg, NewHouse2.jpg, and NewHouse3.jpg in the Preview listview in the New Name column.
  8. Choose the Rename button.

Replacing a word in all names

Lets say we have files NewHouse1.jpg, NewHouse2.jpg, and NewHouse3.jpg. And we want to rename them to New Car 1.jpg, New Car 2.jpg, and New Car 3.jpg.

  1. Select our three files in panel.
  2. Open the Batch Rename dialog box.
  3. Go to the Search for combo box and type word "House" here.
  4. Go to the Replace with combo box and type word " Car " here.
  5. Now you should see New Car 1.jpg, New Car 2.jpg, and New Car 3.jpg in the Preview listview in the New Name column.
  6. Choose the Rename button.

Removing spaces from all names

Lets say we have files New Car 1.jpg, New Car 2.jpg, and New Car 3.jpg. And we want to rename them to NewCar1.jpg, NewCar2.jpg, and NewCar3.jpg.

  1. Select our three files in panel.
  2. Open the Batch Rename dialog box.
  3. Go to the Search for combo box and type one space character here.
  4. Clear the Only once in each name check box.
  5. Now you should see NewCar1.jpg, NewCar2.jpg, and NewCar3.jpg in the Preview listview in the New Name column.
  6. Choose the Rename button.

Reordering words in names

Lets say we have files The Beatles - Yellow Submarine - Revolver.mp3, The Beatles - Michelle - Rubber Soul.mp3, and The Beatles - Yesterday - Help!.mp3 and we want to swap an album name (third part of the name) for a track name (second part of the name). So we want to rename them to The Beatles - Revolver - Yellow Submarine.mp3, The Beatles - Rubber Soul - Michelle.mp3, and The Beatles - Help! - Yesterday.mp3.

  1. Select our three files in panel.
  2. Open the Batch Rename dialog box.
  3. Select the Regular expression check box.
  4. Select the Exclude extension check box.
  5. Go to the Search for combo box and type "(.*) - (.*) - (.*)" here. This regular expression contains: ".*" (any character repeated zero or more times), "()" (each subexpression is enclosed in parenthesis), " - " (just a substring used as a delimiter in filenames). Meaning of this expression is: find three substrings delimited by " - ".
  6. Go to the Replace with combo box and type "$1 - $3 - $2" here. This expression contains: "$1", "$2", and "$3" (the first, second, and third matched subexpressions), and " - " (again just a substring used as a delimiter in filenames).
  7. Now you should see The Beatles - Revolver - Yellow Submarine.mp3, The Beatles - Rubber Soul - Michelle.mp3, and The Beatles - Help! - Yesterday.mp3 in the Preview listview in the New Name column.
  8. Choose the Rename button.

Using structured name to create directory structure

Lets say we have files The Beatles - Revolver - Yellow Submarine.mp3, The Beatles - Rubber Soul - Michelle.mp3, and The Beatles - Help! - Yesterday.mp3. We want to create directory The Beatles with subdirectories Revolver, Rubber Soul, and Help!, and move MP3 files to these subdirectories only with the last part of name (a track name).

  1. Select our three files in panel.
  2. Open the Batch Rename dialog box.
  3. Choose the Rename Relative Path option from the Options menu.
  4. Clear the Only once in each name check box.
  5. Go to the Search for combo box and type " - " here.
  6. Go to the Replace with combo box and type "\" here.
  7. Now you should see The Beatles\Revolver\Yellow Submarine.mp3, The Beatles\Rubber Soul\Michelle.mp3, and The Beatles\Help!\Yesterday.mp3 in the Preview listview in the New Name column.
  8. Choose the Rename button.

Moving all files from subdirectories into one directory

Lets say we have two directories Car and House, and four files Car\1.jpg, Car\2.jpg, House\3.jpg, and House\4.jpg (two files in each directory). We want to move them to one directory Photos, so we want to rename them to Photos\1.jpg, Photos\2.jpg, Photos\3.jpg, and Photos\4.jpg.

  1. Select directories Car and House in panel.
  2. Open the Batch Rename dialog box.
  3. Select the Include subdirectories check box.
  4. Choose the Rename Relative Path option from the Options menu.
  5. Choose the Remove Emptied Directories option from the Options menu.
  6. Select the Regular expression check box.
  7. Go to the Search for combo box and type ".*\\" here. This regular expression contains: ".*" (any character repeated zero or more times) and "\\" (a backslash character). Meaning of this expression is: find the longest substring ending with a backslash.
  8. Go to the Replace with combo box and type "Photos\" here.
  9. Now you should see Photos\1.jpg, Photos\2.jpg, Photos\3.jpg, and Photos\4.jpg in the Preview listview in the New Name column.
  10. Choose the Rename button.

Removing only periods that are not surrounded by digits

Lets say we have directories Altap.Salamand.2.5 and Altap.Salamand.2.0. We want to rename them to Altap Salamand 2.5 and Altap Salamand 2.0.

  1. Select our two directories in panel.
  2. Open the Batch Rename dialog box.
  3. Select the Regular expression check box.
  4. Clear the Only once in each name check box.
  5. Go to the Search for combo box and type "(?<=\D)\.|\.(?=\D)" here. This regular expression contains: "(?<=\D)" (positive look behind for non-digit character ("\D")), "\." (a period character), "|" (delimits two alternative expressions), and "(?=\D)" (positive look ahead for non-digit character ("\D")). Meaning of this expression is: find a period character which is preceded or followed by a non-digit character.
  6. Go to the Replace with combo box and type one space character here.
  7. Now you should see Altap Salamand 2.5 and Altap Salamand 2.0 in the Preview listview in the New Name column.
  8. Choose the Rename button.

See Also

Batch Rename dialog box

© 2001-2019 ALTAP. All rights reserved.


Batch Rename dialog box

Altap Salamander: Plugins: Renamer: Dialog Boxes

Batch Rename

Use this dialog to rename many files and directories in a batch using specified rules.

Menu

The Batch Rename dialog contains menu with following commands:
Commands/Rename
Starts batch renaming. It changes filenames on disk according to rules specified in this dialog. It can also move files to another directories if you rename filenames including their full or relative paths.
Commands/Validate
Tries if batch renaming will succeed. It reports syntax errors in new filenames, duplicate filenames (more original filenames with the same resulting name), and some other errors. Use this command to prevent only partially finished batch rename operation.
Commands/Undo
Reverts all performed rename operations in the last batch (the last use of the Rename command).
Commands/Exit
Closes this Batch Rename dialog.
Edit/Store List to Clipboard
Works only in the manual mode of the batch rename, see the Manual mode checkbox. Copies the list of new names to clipboard, so you can e.g. paste it to your favorite text editor to edit them.
Edit/Load List from Clipboard
Works only in the manual mode of the batch rename, see the Manual mode checkbox. Replaces the list of new names by a text from the clipboard, so you can use it e.g. to copy the changed list of new names from your favorite text editor back to this dialog.
Edit/Open List in External Editor...
Works only in the manual mode of the batch rename, see the Manual mode checkbox. It saves the list of new names to a temporary file, opens this file in your favorite text editor, and waits until you finish editing and save changes. Then it loads back the list of new names from this temporary file. You can specify your favorite text editor in the Advanced Options dialog.
Edit/Filter List Through Shell Command...
Works only in the manual mode of the batch rename, see the Manual mode checkbox. It executes specified shell command (or any command line application) and sends it the list of new names to the standard input. The standard output of this shell command is used as the new list of new names.
View/Sort by Original Name
Changes sorting of items in the Preview listview to sorting by the Original Name column.
View/Sort by Size
Changes sorting of items in the Preview listview to sorting by the Size column.
View/Sort by Time
Changes sorting of items in the Preview listview to sorting by the Date and Time columns.
View/Sort by Path
Changes sorting of items in the Preview listview to sorting by the Path column.
View/All Files
Displays all files in the Preview listview.
View/Successfully Renamed Files
Displays only successfully renamed files in the Preview listview.
View/Not Renamed Files
Displays only not renamed files in the Preview listview. Renaming of these files has failed, you can try to correct their new names.
Options/Rename Filenames
Choose this option if you want to work only with filenames without paths.
Options/Rename Relative Path
Choose this option if you want to work with filenames with relative paths. It has sense only if you want to rename files in subdirectories selected in panel before opening of the Batch Renamer dialog. You need also to select the Include subdirectories check box. It enables you to move files to another directories.
Options/Rename Full Path
Choose this option if you want to work with filenames with full paths. It enables you to move files to another directories and drives.
Options/Remove Emptied Directories
When you rename (move) files to another directories, some of original directories can be emptied (all files from these directories are moved away). Check this option if you want to delete such empty directories.
Options/Last Used
Sets all options in this dialog to values used in the last batch rename operation. Use this command to easily repeat the same batch rename operation.
Options/Reset
Sets the default values to all options.
Options/Advanced...
Opens the Advanced Options dialog.
Help/Batch Rename Dialog
Displays this help page.
Help/Regular Expressions
Displays the Regular Expressions help page.

Options

Mask
You can filter files for batch rename operation by this mask. It's especially important when you rename files in subdirectories (e.g. you want to rename only *.htm files).
Include subdirectories
When checked, you are working with all files contained in selected subdirectories in panel (instead of working with selected subdirectories).
Rename/Validate/Undo
See commands in menu Commands.
Manual mode
When checked, you can edit a list of new names as a plain text directly in this dialog, using an external text editor, or change these names using a command line application.
New name
Specify a template for a new name here. You can use predefined variables containing various useful values (e.g. an original file name, a file extension, a counter). Click the button next to the combo box to see a context menu with all these variables.
Search for/Replace with
You can search for a substring in the new name and replace it with something else. You can use also regular expressions here, it can be used for sophisticated substitutions and reordering of words in the new name. Click buttons next to the combo boxes to see context menus with parts of regular expressions.
Case sensitive
When checked, searching for a substring is case sensitive. Otherwise, searching is not case sensitive (upper and lower case characters are equal).
Only once in each name
When checked, only one substring is replaced in each name (other occurrences of the substring are ignored).
Whole words
When checked, a found substring must be preceded and followed by a space, tab, or punctuation character, or be at the start or end of the name. Otherwise, the found substring may be a fragment of a larger string.
Regular expression
When checked, the Search for field contains a regular expression. Otherwise, it contains a plain text. See description of regular expressions.
Exclude extension
When checked, searching for a substring is performed only in a name part of the new name (the extension part of name is ignored).
File name
You can choose upper/lower/mixed case for a name part of the new name here.
Extension
You can choose upper/lower/mixed case for an extension part of the new name here.
Include path part
When checked, changing of case of a name part is applied also to a path part of the new name.
Preview
You can see all planned changes in a real-time preview of resulting names. Columns contain original names, new names, sizes, dates, times, and paths. New names are displayed in a gray color if they are the same as original names. You can sort this preview by clicking on column headers or in the View menu.

See Also

Batch Renaming

© 2001-2019 ALTAP. All rights reserved.


Renamer Advanced Options dialog box

Altap Salamander: Plugins: Renamer: Dialog Boxes

Renamer Advanced Options

Use the Advanced command from Options menu in the Batch Rename dialog box to open the Advanced Options dialog. You can specify advanced options in this dialog.

Options

External editor settings for manual mode: Command/Arguments/Initial Directory
Specify here how to start your favorite text editor. It will be used for editing of a list of new file names in the manual mode of the Batch Rename dialog.
Manual mode font
Choose a font for edit box with a list of new file names in a manual mode (selected Manual mode check box) of the Batch Rename dialog.
Closing the main window with Escape key
When checked, you can close the Batch Rename dialog by the Escape key. Otherwise, you need to use the Alt+F4 key.
© 2001-2019 ALTAP. All rights reserved.


Regular Expressions

Altap Salamander: Plugins: Renamer: Appendix

Regular Expressions in Renamer Plugin

The Renamer plugin uses more powerful regular expressions than Find and Internal Viewer in Altap Salamander. It extends REGEXP library, which is a great work of Henry Spencer. First see the Regular Expressions Syntax in Altap Salamander and then continue with description of Renamer extensions. These extensions were inspired in Perl.

Extended syntax

  • '*?' - non-greedy variant of '*' (match 0 or more times)
  • '+?' - non-greedy variant of '+' (match 1 or more times)
  • '??' - non-greedy variant of '?' (match 0 or 1 times)
  • '$' - at the end of the expression matches the end of a line (or before newline at the end)
  • '( )' - glues expressions in parentheses to one expression and captures a matched substring (see this example to understand how it works)
  • '(?: )' - works like "( )", but does not capture a matched substring

Note: "non-greedy" means that it matches the minimum number of times possible.

Zero-width assertions

You can use following zero-width assertions (it does not match any character, just test if some condition is true or not):

Assertion | Meaning
\b | Match a word boundary.
\B | Match a non-(word boundary).
\A | Match only at beginning of string.
\Z | Match only at end of string, or before newline at the end.
\z | Match only at end of string.
(?= ) | Positive look-ahead assertion (for example, 'j(?=ohn)' matches 'j' in word 'john' but not in word 'june').
(?! ) | Negative look-ahead assertion (for example, 'j(?!ohn)' matches 'j' in word 'june' but not in word 'john').
(?<= ) | Positive look-behind assertion (for example, '(?<=joh)n' matches 'n' in word 'john' but not in word 'joan').
(?<! ) | Negative look-behind assertion (for example, '(?<!joh)n' matches 'n' in word 'joan' but not in word 'john').

Within character classes "\b" represents backspace rather than a word boundary.

POSIX character classes

You can use following POSIX character classes:

Class | Backslash Equivalent | Meaning
alpha |  | Alphabetic characters.
alnum |  | Alphanumeric characters.
ascii |  | ASCII characters.
cntrl |  | Control characters.
digit | \d | Decimal digits.
graph |  | Characters that are both printable and visible (a space is printable but not visible).
lower |  | Lowercase alphabetic characters.
print |  | Printable characters (characters that are not control characters).
punct |  | Punctuation characters (characters that are not letters, digits, control characters, or space characters).
space | \s | Spacing characters (e.g. space, TAB, formfeed).
upper |  | Uppercase alphabetic characters.
word | \w | Alphanumeric characters plus underscore ("_").
xdigit |  | Characters that are hexadecimal digits.

You can negate the character classes by prefixing the class name with a '^'.

Usage: [[:alpha:]] (alphabetic characters), [01[:alpha:]%] (alphabetic characters plus 0, 1, and %), [[:^digit:]] (all characters except decimal digits).

Short forms of some character classes

You can use following short forms of character classes:

Class | Meaning
\w | Alphanumeric characters plus underscore ("_").
\W | All characters except alphanumeric characters and underscore ("_").
\s | Spacing characters (e.g. space, TAB, formfeed).
\S | All characters except spacing characters (e.g. space, TAB, formfeed).
\d | Decimal digits.
\D | All characters except decimal digits.

Special characters

You can use following special characters:

Special character | Meaning
\t | tab
\n | newline
\r | return
\f | formfeed
\a | alarm (bell)
\b | backspace
\x5A | character 'Z' with ordinal 0x5A (hexadecimal value)
© 2001-2019 ALTAP. All rights reserved.