Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information.
PDF generated at: Thu, 31 Jan 2019 23:32:55 CET
ReNamer User Manual
www.den4b.com
Contents
Articles
Basics 1
ReNamer 1
Introduction 2
Quick Guide 3
Step-by-step 4
Adding files and folders 4
Managing Rules 8
Previewing Files 11
Renaming Files 12
Rules 14
Using the Rules 14
Overview of Rules 14
Insert Rule 15
Delete Rule 17
Remove Rule 18
Replace Rule 20
Rearrange Rule 22
Extension Rule 24
Strip Rule 25
Case Rule 26
Serialize Rule 28
Randomize Rule 30
Clean Up Rule 31
Translit Rule 33
Regular Expressions Rule 37
Pascal Script Rule 39
User Input Rule 42
Reformat Date Rule 44
Pascal Script 46
Pascal Script 46
Quick Guide 48
Types 51
Functions 53
User Scripts 69
Appendices 71
Using Presets 71
Manual Editing 77
Analyze 79
Program settings 80
Main Menu and Keyboard Shortcuts 86
Menus for the Files Pane 88
Context Menus 95
Date and Time Format 97
Binary Signatures 98
Meta Tags 101
Analyze 102
Regular Expressions 104
Command Line Mode 111
Sorting Files 114
Using Masks 115
Renaming Folders 116
Renaming to Another Folder 117
Failed Renaming 118
Validation of New Names 119
Examples of rules 119
Examples of Rearrange rule 121
References
Article Sources and Contributors 134
Image Sources, Licenses and Contributors 136
Article Licenses
License 138
1
Basics
ReNamer
ReNamer is a very powerful and flexible file
renaming tool.
ReNamer offers all the standard renaming
procedures, including prefixes, suffixes,
replacements, case changes, removing the
content inside brackets, adding number
sequences, changing file extensions, etc.
Advanced users can program their own
algorithm using PascalScript rule.
ReNamer allows you to combine multiple
renaming actions as a rule set, which can be
saved, re-loaded, and edited. In addition, it
can rename folders and process regular
expressions. It can handle Unicode
(non-English scripts).
ReNamer supports a variety of meta tags,
such as: ID3v1
[1]
, ID3v2
[1]
, EXIF
[2]
, OLE
[3]
, AVI
[4]
, MD5
[5]
, CRC32
[6]
, SHA1
[7]
and many more.
References
[1] http://en.wikipedia.org/wiki/ID3
[2] http://en.wikipedia.org/wiki/EXIF
[3] http://en.wikipedia.org/wiki/Object_Linking_and_Embedding
[4] http://msdn.microsoft.com/en-us/library/ms779636.aspx
[5] http://en.wikipedia.org/wiki/MD5
[6] http://en.wikipedia.org/wiki/CRC32
[7] http://en.wikipedia.org/wiki/SHA1
Introduction 2
Introduction
ReNamer is a very powerful and flexible file renaming tool with the following features:
• The workflow toolbar makes renaming easy.
• ReNamer can rename files belonging to different folders (or even different computers) at a time.
You can also filter the contents of the folders before renaming.
• ReNamer offers extensive set of rules for renaming. Each rule has controllable parameters.
•
• ReNamer can stack multiple rules in any sequence and apply in that order.
• ReNamer provides full preview (the affected file names can be highlighted).
• ReNamer allows you to try out the stack of rules on user-defined text
(this allows safe experimentation, without risking real files).
•
• ReNamer can automatically handle name-conflicts arising from the renaming.
• You can save the stack of rules as a "preset" and re-use it later with a keyboard shortcut.
• ReNamer can rename folders.
• ReNamer can move files to other folders.
•
• ReNamer can rename Windows network (neighbourhood) files also.
• ReNamer can use RegEx (Regular Expressions) for the renaming.
•
• ReNamer supports Unicode filenames (e.g. Asian scripts, Cyrillic, French, Spanish, Arabic, Hebrew, etc).
• ReNamer allows scripting (Pascal Script) to create complex renaming logic.
(many scripts are available on the Forum
[1]
).
• ReNamer can extract a large variety of meta tags from files and use them for the renaming.
(e.g. ID3v1
[2]
, ID3v2
[3]
, EXIF
[4]
, OLE
[3]
, AVI
[4]
, MD5
[5]
, SHA1
[5]
, CRC32
[6]
, etc)
•
• ReNamer can export/import the renaming-related information.
• ReNamer can take automatic actions based on outcome of renaming operation
(e.g. clear off all successfully renamed files from the pane, but retain the problematic files)
• ReNamer can be run in command line mode, with lots of parameters.
This allows you to select your files in explorer (or any other application) and do one-touch renaming.
Introduction 3
References
[1] http://www.den4b.com/forum/
[2] http://www.id3.org/ID3v1
[3] http://www.id3.org/
[4] http://exif.org
[5] http://en.wikipedia.org/wiki/Sha1
[6] http://en.wikipedia.org/wiki/Crc32
Quick Guide
The ReNamer interface is shown below. Click on any part of the screenshot to see full description.
Using ReNamer is very simple. Just follow the four steps shown below.
Step What to do
1 Select the files from various folders and add them to the working area.
a. Change the default behavior for the "Add Folders" button (optional step).
b. Add individually selected files (Add Files) and/or all files in selected folders (Add Folders), and/or...
c.
c. Drag-n-drop files from Windows Explorer (or any other application) into this area (called "Files pane").
2 Add rules to create a sequence of operations. Delete or edit an existing rule. Change the order of the rules.
a. Allows addition and deletion of rules. Also change the order of any rule in the stack.
b.
b. Click in this area to add a rule (or to edit an existing rule, or just move it to a new position in the list).
3 Preview the results (check before proceeding with the actual renaming).
a. Set options (e.g. highlight changed names, experiment with your own text, resolve conflicts, etc.).
b. Click to see preview of the new file names in the bottom pane (not required in auto-preview mode).
4 Press this button to rename files and folders.
ReNamer is so intuitive that you would be able to use it without reading the manual any further.
Quick Guide 4
The rest of the chapters provide more details on all aspects of ReNamer. Use them as reference.
There is an older version of this guide available here: Quick Start.
Step-by-step
As discussed before in the Quick Guide, ReNamer is used in just four steps, which are explained in this section
(follow the links):
1. Load the files and/or folders to be renamed.
2. Load the renaming rules in a stack.
3. Preview the renamed files/folders to check if the result is as expected.
4. Rename the files/folders.
Adding files and folders
In this section, we will see how to place files and folders in ReNamer's working area (also called the Files pane).
This consists of:
1.
1. Adding files and folders,
2.
2. Removing some files from the pane, and
3.
3. Changing the order of files in the pane.
ReNamer has multiple methods for these actions, as described below
Adding files and folders 5
Adding files using the 'Add Files' button
1. Press the button. The following window pops up:
2. Navigate to the required folder and select files.
3. Press OK. The selected files are added to ReNamer's Files pane.
4.
4. Repeat steps 1-3 to load files from other folders (as required).
Adding files and folders 6
Adding items using the 'Add Folders' button
1. To add all the files belonging to a folder, press the button.
The following window pops up:
• When you select a node in the tree, all its sub-nodes are automatically selected.
In other words, when you select a folder, its subfolders are automatically selected.
• By default, ReNamer adds all files from a folder, but not the folder itself.
So if you want to rename the folder itself (and not its contents), then select this option using the Filters.
•
• You can select any node from the tree. That means you can even select any/all drives on your computer!
• You can select multiple nodes at a time, by pressing CTRL first and then cliking on different nodes of the
tree. All those nodes will be added at one stroke.
2. If you want to add only certain items from the selected folder, set ReNamer's Filters by clicking on the "Filter
Settings" button and then selecting different options. Depending on your selected options in this window, the Add
folders window will add different items to ReNamer's Files pane.
• You can also set the filters by clicking the "Filters" button (located above the Files pane)
3.
3. Navigate to the desired folder and press the "Add Folders" button.
Adding files and folders 7
Adding files using the Drag-and-drop method
Select the files in any application and drag-and-drop them into ReNamer's Files pane.
• To drag-and-drop, click on your file selection with LMB. Without releasing the LMB, start moving the mouse.
Now bring the mouse pointer over the ReNamer's Files pane, and then release the LMB.
• If the ReNamer's window is not visible, first drag your selection onto ReNamer's task button in Windows
Taskbar (normally located at the bottom of your desktop). Wait for a couple of seconds without releasing the
LMB. The ReNamer window pops up, and stays above other applications' windows on your screen. Now you
can move your mouse over the ReNamer window and drop your selection of files.
• You can also configure ReNamer to stay on top of all other windows, so even when you are working in the
other applications ReNamer will remain on top of other windows.
Adding files using the copy-and-paste method
Select the files in any application and press CTRL+C to copy them into the clipboard. Now switch to ReNamer and
press SHIFT+CTRL+V.
Note that:
• Renamer does not use the usual keyboard shortcut CTRL+V.
• It is not necessary to click inside the Files pane for the paste operation.
Removing files or folders from pane
If you have added more files by mistake, you can remove them easily in just two steps:
1. Select the items
2. Press the DEL key. (This only removes the files/folders from the ReNamer. It does not delete them from the
disk!)
Changing the order of the files in the pane
Certain rules (e.g. the Serialize Rule) act on the list of the files in "from-top-to-bottom" order (as opposed to acting
on each file independently). In such cases, each file gets its name based on its position in the list. (For example, the
nth file in the list is named Track-n.mp3.)
Normally, the files are listed in the order you added them to the pane (the most recently added file goes to the bottom
of the list). But you can change the position of the files in the list.
Just click on the file and drag it to the new position.
• You can select multiple files and drag all of them as a group to the new position.
Sorting files in the files pane
You can also sort files in the Files pane by any column with just a click on the column title. The little triangle will
show up to indicate the order of sorting. For more information have a look at the full article on sorting files.
Selecting files
You can carry out various operations on selected files.
To select one or more files:
1.
1. Click anywhere in the row except on the check box.
• To select non-adjacent files, press CTRL and then click on individual rows.
Adding files and folders 8
• To select files listed in adjacent rows, first click on the row at one end, then keep the SHIFT pressed down,
and click on the row at the other end.
2. Draw a lasso (rectangle) with the mouse in the Files pane. All the rows touched by the rectangle are selected.
•
• If you repeat these actions on an item, they toggle the selection status (selected-unselected).
When selecting only one row, use Up and Down arrow keys to change the selection to adjacent row.
Marking and Unmarking the files
A file is marked by putting a tick in its check box . Conversely, it is unmarked by removing the tick .
ReNamer acts only on the marked files. An unmarked file is neither previewed nor renamed.
So unmarking a file is useful to exempt a file from renaming, without having to remove it from the Files pane.
To mark/unmark the files:
1.
1. Click on the check box.
2. Select the files and press the Spacebar (on keyboard)
(Repeat of these actions on any item toggles its marked/unmarked status.)
Note that the marked/unmarked status of a file has no relation with its selected/unselected status.
Managing Rules
This section explains how to add rules, remove rules, edit a rule and change the order in which they are applied to
files and folders.
Adding rules
1.
1. Rules can be added by using any of the following methods:
• Click the button,
• Click inside the Rules area,
• Press the Ins key when the ReNamer window is active.
2. The Add Rule window pops up:
Managing Rules 9
Select the desired rule.
3. The options for the selected rule appear immediately in the Configuration area (at right).
Set the desired parameters, as explained in each rule.
4. Press the button at the bottom of the window. The rule is added to the stack and the window is closed.
5.
5. Repeat steps 1-5 to add more rules. Each new rule is added at the end of the stack.
6.
6. To close the window without adding a rule press the "Close" button (or the window close icon at the top right
corner).
Removing (deleting) rules
To remove an existing rule, select it and press DEL or click on the button.
Changing the order of the rules
All rules are applied to each file in the order they appear. Even with the same set of rules, the end-result can be very
different if the order of the rules is changed.
You can change the order of rules using any of the following methods:
1. Using the and buttons.
2. Pressing CTRL + Up/Down arrows.
3.
3. Drag-and-drop any rule with mouse.
Managing Rules 10
Editing rules
Editing a rule means changing its parameters and options, and then saving the rule.
You can edit a rule using any of the following methods:
1.
1. Double-click on it,
2. Right-click on it and select the Edit Rule option
3. Select it and press ENTER.
A window similar to the Add Rules window appears. There are only two minor differences: the button at the bottom
is titled Save Rule, and the rules list in the left pane is grayed out (because you are not supposed to select rules in
this window).
Change the parameters and options, and press the Save Rule button or ENTER.
Selecting a rule
When a rule is selected, its entire row is highlighted. Only one rule can be selected at a time.
To select a rule, use any of the following methods:
1.
1. Click anywhere in the row except on the check box.
2.
2. Use the Up and Down arrow keys on your keyboard to move the selection to another rule.
Marking and Unmarking a rule
A rule is marked by putting a tick in its check box . Conversely, it is unmarked by removing the tick .
ReNamer uses only the marked rules for the preview and renaming operations.
So unmarking a rule is useful to temporarily disable the rule without having to remove it from the Rules pane.
To mark/unmark the rules:
1.
1. Click on the check box.
2. Select a rule and press the Spacebar (on your keyboard)
(Repeat of any of these actions toggles the marked/unmarked status.)
The reasons for unmarking a rule are:
1.
1. You want to remove the effect of a rule and see what happens to the files.
2.
2. You have a favorite set of rules that you use often. However, you need to remove a few rules in some cases. A
trick is to save the superset of rules and reload them automatically each time you start ReNamer. Then in each
session, unmark some rules.
Previewing Files 11
Previewing Files
ReNamer shows a preview of the files, so that you can decide whether your rules are working as expected. If some
files show unexpected results, edit some of the rules and check the preview again.
Let us see how preview works.
In the example below, there are three rules in the stack:
1.
1. Replaces "." "_" "%20" "-" with a space.
2.
2. Strips the contents of round brackets and removes unnecessary spacing.
3.
3. Capitalizes the first letter of the name and makes all other letters lowercase.
The ReNamer preview is shown below.
We can see that:
• In the Files pane, the State column shows whether the renaming will face any problems. In this case, the green
arrow identifies files that are ready to go, while files with potential problems are marked with a warning sign.
• The New Name column shows a preview of the new names. If you have the Highlight changed names option
enabled all changed names will be highlighted in red during preview. The first name is unchanged, so it is shown
in black. The remaining names are affected by the rules, so they are shown in red.
• The check boxes in the Rules pane allow you to disable any rule temporarily. (Disable one of the rules and see the
effect on the renaming.)
• The check boxes in the Files pane allow you to exempt any file/folder from the current renaming. New names are
not shown for such unmarked files.
There are many program options for previewing and preview process can vary based on those settings. For example,
you can set it to refresh the preview automatically when new files and/or rules are added.
You may also want to customize the columns displayed in the Files pane. For example, many users prefer to see the
Path and New path columns.
Previewing Files 12
•
• To customize columns, right-click on the strip that contains all column-headers. A menu pops up all available
columns. Select the columns you want. From now on, ReNamer remembers the new settings.
Manual Preview mode
If you do not select Automatic Preview mode, you must press the button to see the preview.
This Manual Preview' mode is actually useful if you do not want to miss out the subtle changes that can happen to
the file names when you are adding new rules or if you adjust the file names manually after preview. It can also save
you a lot of time when processing large amount of files, so instead of generagin a preview on every change you can
preview manually only when you need to.
While using the Manual Preview mode, keep the following in mind:
• Files will be renamed exactly as you see in the preview (WYSIWYG policy).
Be sure to press the button after changing your rules, otherwise these changes will not be
applied in the actual renaming!
• If you change the items manually, these changes are lost if you press the button.
Renaming Files
When the button is pressed, the following happens:
1. The marked files are renamed according to the Name and New Name columns (or Path and New Path if
changes affect the full path) in the Files pane.
• If some of the rules do not seem to have applied, the reason could be that the ReNamer is in Manual Preview
mode and you did not refresh the preview after adding/editing some of the rules. To update the preview, press
the button again.
• If your set of rules is not meant to move files from one folder to another, you can as well assume that files are
renamed according to the Name and New Name columns of the Files pane.
2. The Name column now contains the new name of the item, and
3. The New Name column becomes empty
• It is supposed to show a preview of the proposed new name, so once the file is renamed there is no new name
any more.
4. Old names are remembered to allow reverting of the changes using the Undo Renaming option from the Main
Menu.
After the renaming is complete various additional actions can be performed based on Program settings for renaming.
For example, the list of Rules and Files can be automatically cleared off, or program can automatically close.
When is a file considered "renamed successfully"?
Each renaming operation can have one of the following outcomes:
Renaming Files 13
Outcome Is it considered as successfully renamed?
A file that was unmarked (that is, was NOT marked for the current round of renaming) No
A file name that was changed during the renaming operation. Yes
A file name that did not change because none of the renaming rules were applicable. Yes
A file name that caused error during renaming (e.g. invalid file name, name conflict, etc.) No
You can set ReNamer's Program settings to take some conditional actions on the files based on their outcome. For
example, you can clear off the files that were successfully renamed.
Note: When the new name of the file is the same as the original name the renaming operation is still performed, but
without any changes applied. It is important to note that such renaming operation can still fail, for example, because
the original file no longer exists.
14
Rules
Using the Rules
You can load a stack of rules in ReNamer. These rules act on the loaded files in the "top-to-bottom" order. This
allows you to achieve very complex renaming algorithms.
• A rule modifies the name and then passes it to the next rule, which acts on the modified name (not the original
name).
•
• Any rule can be used multiple times, each time with different settings.
All you have to do is to visualize how each rule in the stack affects the file name when the file name "passes
through" the stack.
The first subtopic provides an overview of Rules.
The subsequent subtopics show the specifics of each rule:
•
• How each option works, and how to set it.
•
• Examples (typical uses).
Tip: If you are going to use the same set of rules frequently, it is best to save it as a Preset. This allows you to
re-load the entire set with a keyboard shortcut (such as CTRL+1). A huge timesaver!
Overview of Rules
Overview of Rules
ReNamer has an extensive set of rules. These rules can be combined together, in a logical sequence, to perform
nearly any thinkable operation with the filename. You can also manually edit the name of any file.
The table below lists all rules, with a brief description of each rule.
The subsequent chapters provide more details for each rule (follow the links).
Rules Description
Insert Insert the specified text into the filename: as prefix, as suffix, at the specified position, before- or after the specified text. There is
also an option to insert meta tags into the filename.
Delete Delete a portion of the filename, usually defined by character positions: from the specified position, from the occurrence of the
specified delimiter, until the specified number of characters, until occurrence of the specified delimiter or till the end. This rule can
be set to process the filename in a right-to-left manner.
Remove Remove the specified text from the filename: first, last or all occurrences. Optionally, wildcards can be used within this rule, to
remove masked text fragments.
Replace This rule is very much like the Remove rule (above). It has similar options, except that instead of removing the text fragments, it
will replace them with the specified text.
Rearrange Chop up the existing file name using any delimiter or position and reuse any/all of the parts in any order to compose a new
name.Add your strings, or use the meta tags extracted from the file to compose the new name.
Extension Change extension of files to the specified extension, or to the extension automatically detected through the internal database of
binary signatures.
Overview of Rules 15
Strip Strip all occurrences of the specified characters from the filename. This rule has predefined character sets, like digits, symbols,
brackets, but you can also define your own character set.
Case Change the case of the filename: capitalize each word, to lower case, to upper case, invert case, or capitalize only the first letter and
force the rest to lowercase (as in a sentence). There is also an option to force case for the manually entered fragments, for example:
CD, DVD, India, ReNamer, etc.
Serialize Add incremental numbers to put filenames into an order.
Randomize Add randomly generated sequences into filenames.
CleanUp Cleanup filenames from (or for) commonly used naming conventions for Internet, peer-to-peer networks, and other resources.
Translit Transliterate Non-English characters from different languages into their English/Latin representation. Useful for preparing files for
network storage and transfer. Several transliteration maps are built in, and you can define your own maps.
RegEx RegEx (=Regular Expressions) is used for complex pattern/expression matching and replacing operations.
Although it may look complex at first, you can learn it quite easily, using the guide provided in this manual!
PascalScript Scripting allows programming-aware users to code their own renaming rule using predefined set of functions. This rule uses
Pascal/Delphi programming syntax and conventions. Extremely powerful feature in the right hands.
UserInput Rule that simply sets the new names of the files to the names entered in a list (one name per line).
ReformatDate Change format of date/time values in the filename.
Insert Rule
Insert Rule
This rule inserts the specified string at the beginning of the name, or end of the name, or at any other specified
position. It can also insert the string conditionally (only when the existing name contains a second specified string).
The parameters are as follows:
Insert Rule 16
Parameter Details
What Enter the text that will be inserted.
Insert meta tag
Click the button to see a list of meta-tags.
Where Where to insert the text, select one of the "Where" options described below.
Skip extension If this check box is unselected, the extension will be included in the rule.
"Where" options
Option Details
Prefix Adds the string before the existing name.
Suffix Adds the string after the existing name.
• If the skip extension option is not selected, the specified text will be inserted after the extension.
Position Insert at the set position (the count starts from 1).
•
• Count spaces and special characters also.
• You can count in the right-to-left direction
• You may use Analyze window to check the position by pointing to the character with mouse or keyboard instead of counting it by
yourself. Just select the file (or files) in the Files pane and choose the Analyze name option from the context menu.
After text Inserts the text entered in the "what" box after the text entered in the "after text" box.
•
• If the "after text" string is not found in the name, the "what" text will not be inserted.
Before
text
Inserts the text entered in the "what" box before the text entered in the "before text" box.
•
• If the "before text" string is not found in the name, the "what" text will not be inserted.
Delete Rule 17
Delete Rule
Delete Rule
This rule will delete all characters located between the From and the Until positions. Optionally, it can delete from
the specified position till the end of the name.
The parameters are as follows:
Parameter Details
From From which character-position you want to start the deletion. Select from the following options:
•
• The starting position (count starts from 1)
•
• The delimiter from where the deletion starts.
•
• The delimiter can be a single character or even a string.
• Typically , . / ( ) - and space are used as delimiters.
Until Till which point you want to delete: Select from the following options:
•
• Count: Specify how many characters to be deleted, starting from the FROM position.
•
• Delete till a specified delimiter is reached.
• You can use two different delimiters in From and Until sections.
•
• The delimiter can be a single character or even a string.
• Typically , . / ( ) - and space are used as delimiters.
•
• Delete all characters till the end.
Skip extension If this check box is unselected, the extension will be included in the rule.
Delete Rule 18
Right-to-left If you select this option, ReNamer counts the position from the extreme right. (The From and Until
positions switch places.)
• When this option is selected, the "till the end" option in Until deletes all characters on the left
(what we regard as the beginning of the name)
For example, to keep only the four characters on the right side of the name (and delete all the rest of
the characters on the left), use:
From Until
Position 5 Till the end
Do not remove delimiters If you select this option, the delimiters themselves will be retained.
• If you have used two different delimiters in From and Until sections, both of them will be retained.
Remove Rule
Remove Rule
This rule removes the specified string from the file name. It has options to remove the first occurrence, the last
occurrence, or all the occurrences of the specified string. You can enter multiple strings at a time (just separate them
with *|*). If ReNamer finds any of them in the name, they will be removed. You can create a pattern with wildcards,
so that any string that matches the pattern will be removed.
The parameters are as follows:
Remove Rule 19
Parameter Details
Remove Enter the string to be removed.
•
• You can enter multiple strings at a time. Press the + button to separate two strings
•
• If the name does not contain the specified string, the rule will not act on it.
•
• If the name contains more than one of these strings, it will remove all of them.
TIP: Sometimes, the file names have a common string that needs to be removed. In such cases, rather than entering the whole
string by hand, it is easier to borrow it from one of the file names. To do this, just click on a file name in the Files pane of
ReNamer BEFORE launching the Remove rule. ReNamer will automatically copy the entire name of the selected file into the
Remove field. Now edit this entry to get the desired common string.
button
Inserts a separator (*|*) sequence between two delimiter entries. (You can directly type *|* instead of clicking on this button.)
Occurrences In case the strings occur multiple times in the name, specify which occurrences should be removed. (Options are: first only, last
only, or all)
Skip extension If this check box is selected, the rule won't touch the extension.
Case sensitive Will only remove a specified string from the name if the case matches exactly.
Interpret
symbols as
wildcards
Treat certain symbols as Wildcards for matching simple patterns (similar to Regular Expressions).
Wildcards
Wildcard Represents Example
* any number of characters (including numbers, space, underscores, etc.). abc* equals abc followed by 0 or more
characters.
? Any single character (including numbers, space, underscores, etc.) ab?d equals abcd, ab1d, ab d, ab_d, etc.
[] Brackets enclose a set of characters, any one of which may match a single character at
that position.
foo[ab]ar equals fooaar and foobar
- (only within a pair of brackets) denotes a range of characters. foo[a-z]ar equals fooaar, foobar, foocar,
foodar, etc.
Replace Rule 20
Replace Rule
Replace Rule
This rule removes the specified string from the name and replaces it with another string. It has options to replace the
first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can
create a pattern with wildcards, so that any string that matches the pattern will be removed.
The parameters are as follows:
Parameter Details
Find Enter the string to be replaced.
• You can enter multiple strings at a time. They will be searched & replaced in the order as they appear. Press the +
button to insert a separator between two strings. Instead of pressing this button, you can also enter *|* from the
keyboard.
•
• If the name does not contain the specified string, the rule will not act on it.
•
• If the name contains more than one of these strings, it will replace them according to the Occurrences parameter.
button
Inserts a separator (*|*) sequence between two delimiter entries. (You can directly type*|* You can use this button in the
Replace box also. In that case, the nthe entry in the Find box is replaced by the nths entry in the Replace box. (e.g. A
-->A', B -->B' etc.) }
Replace Enter strings that will replace the "Find" strings.
• Note that the number of strings (separated with *|*) in "Find" and "Replace" boxes should be the same. If there is
more strings in the "Find" box than in the "Replace" box the spare strings will be removed (replaced with an empty
string). If there is more strings in the "Replace" box, the spare strings will be ignored.
Insert meta tag Click the button to see a list of meta-tags.
Occurrences In case that strings occur more than once in the filename, specify which occurrences should be replaced. (Options are:
first only, last only, or all)
Skip extension If this check box is selected, the extension will be ignored by the rule.
Replace Rule 21
Case sensitive Will only remove a specified string from the name if the case matches exactly.
Interpret symbols as
wild cards
Treat certain symbols as Wildcards for matching simple patterns (similar to Regular Expressions).
Wildcards
Wildcard Represents Example
* any number of characters (including numbers, space, underscores, etc.). abc* equals abc followed by 0 or more
characters.
? Any single character (including numbers, space, underscores, etc.) ab?d equals abcd, ab1d, ab d, ab_d, etc.
[] Brackets enclose a set of characters, any one of which may match a single character at
that position.
foo[ab]ar equals fooaar and foobar
- (only within a pair of brackets) denotes a range of characters. foo[a-z]ar equals fooaar, foobar, foocar,
foodar, etc.
Beware of conflicting replacements
If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go
first and only after replacing all (or first, or last) occurrences of that string the second string in the Find box will be
searched & replaced.
Find Replace
A|B B|A
Name New Name
ABBA.mp3 AAAA.mp3
You may expect the new name to be BAAB.mp3, but it's not. This happens because first all A's are replaced with B's
(we get BBBB.mp3) and only then all B's are replaced with A's (and the final result is AAAA.mp3).
If you need to apply character-to-character mappings you should use Translit rule.
Rearrange Rule 22
Rearrange Rule
Rearrange rule
This rule allows you to chop up the existing file name and reuse any/all of the parts in any order to compose a new
name.
•
• You can also add your own text, or use meta tags while composing the new name.
•
• You can also use the whole original name, and insert literal text (or meta tags) around it.
The parameters are as follows:
Parameter Description
Split using Specifies how to split the existing name into parts.
•
• You can use only one of the three options at a time (you cannot combine the chopping methods)
For detailed explanation of split methods please look below at the split options explained section.
Right-to-left If selected, the numbering starts from right.
•
• The characters of the original names are counted from right (the count begins with 1)
•
• The chopped parts will also be numbered from right ($1, $2, etc.)
Add a separator for additional delimiters. The separator is a "|" (vertical pipe) character, which can also be entered manually.
New pattern How to compose the new name from the parts created from the original name (see above).
•
• You can add meta tags and literal text wherever you want.
•
• $0 refers to the whole original name. This allows you to quickly compose a new name by inserting a string at the beginning
and/or end.
Click the button to see a list of meta-tags. Select any meta tag to insert it in the new name template.
Rearrange Rule 23
Split options explained
Option Description
Delimiters Chop the name where the delimiter occurs.
•
• The delimiter can be a single character or a string.
• The chopped parts do not contain the delimiters (they are omitted totally)
•
• Spaces, numbers and symbols are treated like normal characters.
•
• Several delimiters can be used at a time. Use the | character to separate them.
•
• The chopped parts are numbered from left, as $1, $2, $3, etc.
The same parts can be referred from the end as $-1, $-2, $-3, etc.
•
• If the delimiter occurs at the very beginning of the name, the resultant $1 contains nothing (because there is nothing on the left
side of the delimiter).
Warning: The number of parts into which the filename is broken down depends solely on the number of delimiters in the filename.
If you reference fewer parts in the output pattern that the number of available parts - not referenced parts will be lost! For example,
take filename "Artist - Title" and to swap them around one would use " - " as a delimiter and "$2 - $1" as a new pattern which will
result in "Title - Artist", but if some filename appears with more dashes like "Artist - Title - Album" the result will also be "Title -
Artist" and last part will be lost. To make sure that no parts are lost use Exact pattern of delimiters option instead.
Positions Chop the name at the indicated position (the position count begins with 1).
• If you enter position n, ReNamer will chop the n-th character and all characters beyond that in a separate piece.
•
• Spaces, numbers and symbols are treated like normal characters.
•
• No part of the original name is omitted during chopping.
• You can enter multiple positions. Separate them with the *|* sequence.
•
• The chopped parts are numbered from left, as $1, $2, $3, etc.
The same parts can be referred from the end as $-1, $-2, $-3, etc.
Exact pattern
of delimiters
Chop the name using the exact pattern (sequence) of the delimiters.
With this option you basically define how many parts you want the filename to be split into and the order in which the delimiters
must occur. If you specify 1 delimiter then you end up with exactly 2 parts, if you specify 2 delimiters you'll get 3 parts, and so on.
Examples
This rule is so versatile that it can be used in a huge number of ways. Therefore its examples have been moved to a
separate article Rearrange Examples.
Extension Rule 24
Extension Rule
Extension Rule
This rule allows you to attach a new extension. It is useful when the extension of a file is missing (or if the file has a
wrong extension). There is an option to find the correct extension based on the file's structure.
The parameters are as follows:
Parameter Details
New extension New extension that has to be added to the filename.
Append to the original
filename
If this option is selected, the new extension will be placed after the old extension. If it is deselected (default option) the
new extension will replace the old one.
Detect using binary
signature
Try to detect a correct file extension using built-in Binary signatures of commonly used files.
Binary signatures
Sometimes the extension of a file is missing. At other times it is simply wrong, e.g. some downloaded files get the
aspx extension, although they may actually be zip or pdf files. One way to identify the file extension is by
trial-and-error: Attach different extensions and try to open the file with its associated application. This is very
tedious.
A far more efficient way is to compare the file's digital signature with the signatures of known file types and identify
the file's type. This is done internally within ReNamer, so you do not have to know what a digital signature means,
or the actual value of the signature for the given file.
Note that each extension has a range of signatures, and these ranges overlap. This means a given file's signature may
match with the signature of several different extensions. In such cases, ReNamer shows the New filename with all
matching extensions. For example, "fileName.wma|wmv|asf". ReNamer also pops up an error window
(because the combined extension is invalid). Just read the suggested extensions and then try them out one by one.
This method is still better compared to making wild guesses, because ReNamer suggests only 2-3 extensions.
Extension Rule 25
For more accurate results, use ReNamer with TrID library, a specialized utility for identifying the file's real
extension. Be aware that even TrID often suggests multiple extensions, and you may still have to try them out.
Strip Rule
Strip Rule
Strip characters from the filename. The rule has predefined character sets, like digits, symbols and brackets, but you
can also define your own character set. Every occurrence of each of the specified characters will be removed from
the filename.
The parameters are as follows:
Parameter Details
English
Strip all English characters (both capital and small).
•
• Numbers (0-9) will not be stripped.
• Non-English characters will not be stripped.
(e.g. characters with diacritical mark
[1]
, which are used in many languages in Europe and Asia)
Digits Strip digits
Symbols Strip symbols (all characters that are considered to be symbols are showed in the box on the right)
Brackets Strip brackets (but not the contents of the brackets)
• If you want to delete the content as well, use the CleanUp rule instead.
User-defined Define any character that needs to be stripped off.
•
• Note that this is not a string. All characters in the entry are searched for individually and removed.
Strip all characters except
selected
Retains the selected characters only, and strips the rest.
• This option is very useful to strip all non-English characters: Select this option along with the English option
above.
Skip extension If this check box is selected, the extension will be ignored by the rule.
Strip Rule 26
References
[1] http://en.wikipedia.org/wiki/Diacritic
Case Rule
Case Rule
This rule changes the case of the filename. Options are: capitalize, to lower case, to upper case, invert case, and put
only first letter capital (as in a sentence).
There is also an option to force case for specific text-fragments, such as CD, DVD, RF, etc. These fragments would
not look natural in any other case (e.g. cd, dvd, rf), so the rule allows you to prevent changing the case of such terms
in one stroke.
The parameters are as follows:
Parameter Details
Case change Several options are offered.
• The case of each option itself illustrates how that option works. For example, Capitalize Every Word.
• Capitalize Every Word will first make all letters lowercase and then convert the first letter of each word into UPPERCASE.
• Capitalize AND Preserve will convert the first letter of each word into UPPERCASE; but will not affect the rest of the letters.
• all lower case will convert all letters to lowercase.
• ALL UPPERCASE will convert all letters to UPPERCASE.
• iNVERT cASE will change all capital letters to lowercase, and all lowercased letters to UPPERCASE.
• First letter capital will change only the first letter to UPPERCASE, and rest of the letters to lowercase. (Compare this with
the Capitalize AND Preserve option above.)
Case Rule 27
• The (none of the above) option is provided to disable the case conversions listed above it, so you could independently use the
options listed on the right side of the window. This allows you to convert the case of extension, or case-convert specific text
fragments (see below).
Skip extension If this check box is selected, the extension will be ignored by the rule.
Force case for
fragments
This option forces the case of specified text-fragments (strings) in the file name.
Note: This check box is coupled with the box below it. (Enter the fragments in the box and then activate the option by selecting
the check box.)
•
• You can set any case for the strings (ALLCAPS, Only first letter capitalized, lowercase, MixedCase, etc.)
• You can specify multiple strings at a time, each with its own case format. To separate the strings from each other, put a comma
between them.
(Note: In versions prior to v5.50, a space was used instead of a comma.)
• The case for these strings will be set exactly as entered in the box, regardless of the options selected in Case change list.
Extension
always upper
case
Forces the extension to uppercase. Note: This setting overrides any other setting that can alter the extension. For example,
consider a case where the all lowercase option is selected and the skip extension option is deselected. Logically, the extension
should be converted into lowercase too. But if the Extension always upper case option is selected, the case of the extension will
be converted to uppercase. This setting will override even the fragments case-conversion.
Extension
always lower
case
Forces the extension to lowercase. Note: This setting overrides any other setting that can alter the extension. For example,
consider a case where the ALL UPPER CASE option is selected and the skip extension option is deselected. Logically, the
extension should be converted into ALLCAPS. But if the Extension always lower case option is selected, the case of the
extension will be converted to lowercase. This setting will override even the fragments case-conversion.
Examples of Force case option
You may want to use a very specific case format for certain text fragments, irregardless of other case options.
Here are some typical examples where "Force case" option may be useful:
Desired case format Examples
ALLCAPS CD, DVD, TV, HTML, XML, C++, USA, GIMP
Only the First letter capitalized Java, India, English, Sunday, Easter, February
Mixed case OpenSUSE, OpenOffice, ReNamer
Serialize Rule 28
Serialize Rule
Serialize Rule
This rule works on a set of files, and inserts incremental numeric series of digits in the names of those filenames.
The files listed in the pane can be numbered in increasing or decreasing order, with various steps, repeat and reset
configuration. The position of each file in the Files pane becomes important, so check the order of the files in the list
before applying this rule.
Examples:
1.
1. You have a bunch of log files, and you want to make them look like "log0001", "log0002", "log0003", etc.
2.
2. You want to force specific sorting for files: "01 - Song XYZ", "02 - Song ABC", "03 - Song YYY", etc.
The parameters are as follows:
Parameter Description
Index start Starting number. For example, if the destination folder already has some files with serialized numbers, you can start with the
next number.
Step Increment the index by this value after each processed file. Usually 1, but you may like to enter a higher number here if files
with intermediate numbers are expected later. Also, negative numbers can be used to make decremental indexes, e.g. -1, -2, -3,
etc.
Repeat How many times to repeat (reuse) the same index before incrementing it.
Reset every Reset index to the initial value after processing this many files.
Reset if folder
changes
Since ReNamer can work on files collected from multiple folders, this control allows you to reset the counter for each of those
folders. The effect is as if you are repeating the same command for each of the folders separately.
Serialize Rule 29
Reset if file name
changes
Reset the counter when the file name changes. This option is especially useful for fixing (serializing) duplicated file names,
when the files with the same name are grouped together, which can be achieved by sorting the files by name or path.
Pad with zeros to
length
Pad the inserted number with leading zeros. For example, "457" becomes "000457" if it is padded to reach 6 digits, and "0457"
if padded to 4 digits.
Insert where Specify where to insert the number (see below for individual options).
Insert location
Options for where to insert the number:
Option Description
Prefix Before the original filename
Suffix After the original filename
Position Insert the number at the specified position.
Replace current name Inserted number replaces the entire filename.
Skip extension Exclude file extension when calculating the position for insertion.
Numbering system
A choice of the Numbering system dictates which symbols and enumeration technique are used for the serialization.
Number system Description / Examples
Decimal digits Index starts at 0 with repeat 1 and step 1:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, …
English letters Index starts at 1 with repeat 1 and step 1:
a, b, c, …, x, y, z, ba, bb, bc, …, bx, by, bz, ca, cb, cc, …, zx, zy, zz, baa, bab,
bac, …
Index starts at 1 with repeat 1 and step 1, pad to length 3:
aaa, aab, aac, …, aax, aay, aaz, aba, abb, abc, …, abx, aby, abz, aca, acb, acc, …,
azx, azy, azz, baa, bab, bac, …
Roman
numerals
Index starts at 1 with repeat 1 and step 1:
I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, …
Simplified
Chinese
Index starts at 1 with repeat 1 and step 1:
一, 二, 三, 四, 五, 六, 七, 八, 九, 一十, 一十一, 一十二, 一十三, …
Custom
alphabetic
Index starts at 1 with repeat 1 and step 1, using "ABC" symbols:
A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, …
Index starts at 1 with repeat 1 and step 1, using "01" symbols:
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, …
Custom numeric Index starts at 0 with repeat 1 and step 1, using "ABC" symbols:
A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, …
Index starts at 0 with repeat 1 and step 1, using "01" symbols:
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, …
Randomize Rule 30
Randomize Rule
Randomize Rule
This rule inserts randomly generated sequences of specified length and using a selection characters (digits, letters, or
a custom set).
Several common practical uses:
1.
1. Randomize the order files.
2.
2. Destroy existing filenames.
The parameters are as follows:
Parameter Description
Length of random
sequence
Specify how many characters your random sequence should have.
For example, if you are using only digits and set length to 4, you will will get random numbers from 0000 to 9999
(inclusive).
Unique if possible Normally, randomly generated values can repeat themselves. If this option is selected, ReNamer will generate unique
values (no repetition) when possible.
Characters to use The set of characters which will be used for generating random sequences.
You can choose between using digits (0..9), English letters (a..z) or specify your custom set of characters.
Insert where Specify where to insert the number (see below for individual options).
Options for where to insert the number:
Randomize Rule 31
Option Description
Prefix Before the original filename
Suffix After the original filename
Position Insert the number at the specified position.
Replace current name Inserted number replaces the entire filename.
Skip extension Exclude file extension when calculating the position for insertion.
Clean Up Rule
CleanUp Rule
This rule cleans up the filenames from (or for) commonly used naming conventions for Internet, peer-to-peer
networks and other resources. Multiple problems can be removed at once.
The parameters are as follows:
Clean Up Rule 32
Parameter Details
Strip out content of
brackets
A typical use of this option is to strip the needless comments attached to filenames, such as (best!!).
•
• This option removes the brackets also.
•
• You can select any/all of the various types of brackets.
If you do NOT want to delete the content within the brackets, use the Strip rule instead.
Replace these
characters with spaces
These characters occurring in the file names are removed and a space is inserted in their place.
Fix spaces Replace multiple consecutive spaces with a single space. It also removes spaces from the beginning and the end of the
filename:
• If skip extension is selected it removes spaces from the beginning and end of the base name (before the extension).
• If skip extension is deselected it removes spaces from the beginning and from the end of the filename (after the
extension).
Normalize unicode
spaces
Replace all Unicode white space characters with a standard space bar character code. Unicode character set contains a
number of different characters (C1_SPACE type) that represent a white space with slightly different properties (e.g.
wider, narrower, etc).
Insert a space in front
of capitalized letters
Often words in the file name are just joined together, without spaces or underscores to separate them. Each word begins
with a capital letter, so that you can read it easily.
This option separates such words in the file name.
For example, SeparateTheseWords.pdf becomes Separate These Words.pdf.
(Note that if there is a capitalized letter at the very beginning of the name, ReNamer does NOT add a space before it.)
Prepare for SharePoint
Prepares the file for hosting it on Microsoft Sharepoint
[1]
.
1.
1. strips standard forbidden filename characters
2.
2. strips consecutive dots
3. strips #, %, ~, &
4. replaces { and } with ( and )
Skip extension If this check box is selected, the extension will be ignored by the rule.
References
[1] http://www.microsoft.com/sharepoint/prodinfo/what.mspx
Translit Rule 33
Translit Rule
This rule transliterates one alphabet into another. Its main goal is to transliterate Non-English characters from
different languages into their English/Latin representation. For example, the German character ü can be transliterated
to ue (the name Müller can be also written as Mueller).
This rule uses transliteration maps (explained below).
Transliteration maps
To transliterate, we create a pair of equivalent characters, like this: ü=ue
(Note that the right side of this equation has two characters. Any number of characters may be placed on both sides
of the equation.)
We need several such equivalent character pairs to convert one language into another. The entire set is called a
transliteration map. (This is really some kind of a find-and-replace rule.)
ReNamer has several such built-in maps. Each map is named after a language (the second language in all maps is
English).
Each map can be used in both directions (e.g. French-to-English or English-to-French.)
When you start up the Translit Rule, its window does not show any maps. You are free to do any of the following:
1. Use any of the built-in maps (and use it in forward or reverse direction)
2.
2. Create your own map and use it.
3.
3. Edit a built-in map first, and then use it.
Let us see how to do this.
Translit Rule 34
Automatic case conversion
Translit rule does automatic case conversion with an algorithm adopted specifically for transliteration. Translit rule
discard the case on the input, i.e. "A=B" is same as "a=b". Case is decided upon case of the input fragment. Multiple
character fragments are treated as part of words, with their case decided based on the case of letters around them.
The logic for the case conversion is as follows (ReNamer Beta from 23 Aug 2009):
set OUTPUT-PART to lower case
if first letter in INPUT-PART is upper case then
if length of OUTPUT-PART bigger than 1 then
if next letter in original name is upper case then
convert whole OUTPUT-PART to upper case
else
convert only first letter in OUTPUT-PART to upper case
else
convert whole OUTPUT-PART to upper case
Using a built-in transliteration map
To select any of the built-in maps, press the button. A list of available transliteration maps pops up:
Click on the desired transliteration map. As an example, let us click on the French (to English) transliteration map.
The Rules window changes immediately to show the French characters and their English equivalents.
Translit Rule 35
You can edit any of the entry in this list, add new entries, or delete any of the entries.
Note that such editing does not alter the saved version of the map. (The map is edited just for a one-time use. So, if
you select the same Translit map again, ReNamer will load the original version, not the edited version.) We will see
how to edit and save a map later.
Next, select the rule's parameters as shown below:
Parameter Details
forward This is transliteration from-left-to-right direction, as defined in the map.
backward This is transliteration from-right-to-left direction, as defined in the map.
skip extension If this check box is selected, the extension will be ignored by the rule.
Finally, press the button to add the rule to the stack.
Making your own transliteration map
Click in the Translit Alphabet window, and start entering your custom alphabet.
Transliteration alphabet consists of two equivalence parts (or a couple), which are entered one per line and two parts
separated with "=" (equal sign). Alphabet should not contain spaces and should have case discarded (case is adjusted
automatically). Also, make sure to put couples which contain greater number of characters at the top, so they will get
processed first and will not get processed partially by shorter representations. Below is a simple example:
щ=sh
ю=yu
я=ya
ь='
э=e
After entering all such transliterations, press the button to add the rule to the rule-stack.
Note that this rule is not saved yet (it was just composed for a one-time use). The following topic shows how to save
a map.
Translit Rule 36
Saving a transliteration map
To save a newly composed Transliteration rule,
1. Press the button.
A menu pops up.
2. Select the last option (Save Translit...).
A window pops up, as shown below:
3. Enter a new name for the map and press OK. The new map is saved.
The process of saving an edited Transliteration map is similar. The only difference is that the Save Translit window
(see above) shows the current map's name. You can press OK to save the changes you've just made, or enter a new
name to create a new translit map for the edited version of the current map.
The new map's name is added to the map list.
From now on, the new map will also be available as "standard".
Regular Expressions Rule 37
Regular Expressions Rule
This rule finds text that matches the specified RegEx pattern, and replaces it with another string. RegEx is short for
Regular Expressions, which stands for special syntax for describing search and replace patterns. Regular
Expressions are very powerful and they are really worth learning. The RegEx syntax is explained in the appendix.
Note: The TRegExpr
[1]
RegEx engine used by ReNamer is a little different from the standard PERL RegEx
[2]
or
Windows RegEx
[3]
. You may check the correct syntax in Regular Expressions section.
The parameters are as follows:
Parameter Details
Expression RegEx pattern to match or find.
Replace RegEx pattern that replaces the found pattern.
Skip extension If this check box is selected, the extension will be ignored by the rule.
Case-sensitive If this option is selected, ReNamer will search for the text in case-sensitive manner.
A simple set of commonly used RegEx syntax patterns is provided in the hint menu:
Regular Expressions Rule 38
Tip: ReNamer users have posted many RegEx patterns at the User Forum
[1]
. You can copy and use them.
References
[1] http://www.regexpstudio.com/
[2] http://perldoc.perl.org/perlre.html
[3] http://msdn.microsoft.com/en-us/library/6wzad2b2(VS.85).aspx
Pascal Script Rule 39
Pascal Script Rule
This rule uses Pascal Script programming engine with syntax and conventions similar to Delphi/Pascal. ReNamer
comes with some preloaded scripts. We will see how to use them, and how to add a new script.
Using a ready script
1. Click on the button (located just below the Configuration pane).
A list of scripts appears.
2. All available scripts are listed above the line. Click on any script to load it into the Configuration pane.
3.
3. Edit the script if required
4. Press button to add the script to the rule stack.
Alternatively, you can drag and drop an existing file from your desktop of favourite explorer straight into the script
window.
Hold SHIFT key when opening a new script to insert it into the current script at the cursor position, instead of
completely replacing the current script. This can be useful when you store your commonly used functions in separate
Pascal Script Rule 40
script files, and with this feature they can be easily merged into the current script.
Borrowing scripts from forum
Even if you do not know how to write a script, you can easily use scripts written by others.
First, visit the User Forum
[1]
and search for a suitable script. The Forum already has a large number of such scripts.
Some of these scripts have embedded comments about how to customize the script. If you cannot find a suitable
script, you can ask other users to write the script for you.
TIP: If you are looking for scripts only, try to use begin or end words in your search phrase as these are the words
that are present in every single script.
Once you find such a script, follow these simple steps:
Step Details
1 Copy the script Copy the script from the forum (ensure that nothing is left out).
2 Clear the ReNamer's Configuration pane Open the Pascal Script Rule in ReNamer. Select the three lines you see in the Configuration
pane, and press DEL or paste the script while these lines are selected.
•
• The three lines already provided in the window are meant to begin a script from scratch; but since you are pasting a ready-made script,
they must be removed first, otherwise they will interfere with your script.
3 Paste the script into ReNamer pane Use the CTRL+V shortcut or right-click and select Paste.
4
Compile the script Press the button.
•
• In case some error comes up, the error message will identify the line number of the faulty statement.
You can try and troubleshoot the problematic statement in the script using the button.
ReNamer opens a window like this:
Now enter the line number in the window and press OK. It takes you to the faulty statement.
Try to edit the statement and compile the script again.
(Note that if the script compiles successfully, the button is not required at all.)
Pascal Script Rule 41
5
Saving the script and giving it a name: The save button is hidden under the scripts menu. So first click on the button. It pops
up a window like this:
Note that all the existing scripts are listed here. (When you save the new script, it will also be added to this list.)
Select the Save script... option (at the very bottom of the menu). Another window pops up.
Enter a name that suggests the function of your script. Press OK. The new name is added to the list of scripts. Now use it as described above.
Writing your own scripts
To write your own scripts, you must have knowledge of Pascal script. Learning Pascal script is easy. Refer to the
Pascal Script section.
Here, we will assume that you already know how to write pascal scripts.
The step-by-step procedure is as follows:
1. Click in the Configuration pane and enter the script directly. (You can also copy it from anywhere and paste it
into the pane by pressing CTRL+V. Or right-click in the pane and select the Paste option from the context
menu.)
2. Compile the script by pressing the button located below the Configuration pane.
• If an error message comes up, troubleshoot the script. The fault message usually includes the line number of
the problematic statement in the script. Press the button and enter that line number to locate the faulty
statement quickly. Then correct the errors and press the button again. Repeat this till a
Compiled successfully! message pops up.
3. Now you can add the script as a rule by pressing button or save it for later use.
4. To save the script press the button. A list pops up:
Pascal Script Rule 42
5. Click on the Save Script...(the last option in the list). Now this script is added to the list (it appears above the line
in the list).
•
• Now you can use that script as described above.
User Input Rule
This rule replaces the original filenames with the names taken from the list. (The nth line in the list serves as the new
name for the nth file in the Files pane.)
Naturally, the list should contain names for all the files loaded in the Files pane.
•
• If the list is shorter, then some of the files will not be renamed.
• If the list is longer, some of the names will remain unused (but all files in the Files pane will be renamed).
There are three ways to create the list:
1.
1. Click in the pane, and manually type the list (one name per line).
2. Copy the list from any application to your clipboard. Switch to ReNamer. Click in the UserInput pane and press
CTRL+V, right-click and select Paste or choose the Load from clipboard from menu).
3. Load a list from the text file (available from menu).
User Input Rule 43
The optional parameters are as follows:
Parameter Description
Insert in front of the
current name
Inserts the name before the file name.
Insert after the current
name
Inserts the name after the current name. The actual position depends on the Skip extension option.
Replace the current
name
Replaces the existing filename with the new name. The effect on extension depends on the Skip extension option:
Skip extension •
• If the option is selected, the extension is ignored and user input strings will affect only the base name of files.
• If the option is deselected, user input strings will replace entire filename, including the extension, or will be added
after the old extension (if the Insert after the current name option is selected).
Examples
For example, if you have this three files:
•
• Old name 1
•
• Old name 2
•
• Old name 3
Then your list of new names should contain exactly three lines like:
•
• New name for old name 1
•
• new name for old name 2
•
• New name for old name 3
Example 1
File list is longer then the list of new names:
File name List of new names
One.txt First.txt
Two.txt Second.txt
Three.txt Third.txt
Four.txt (will not be renamed)
Example 2
List of new names is longer then the file list:
User Input Rule 44
File name List of new names
One.txt First.txt
Two.txt Second.txt
Three.txt Third.txt
(not used) Fourth.txt
Example 3
Missed item in the list of new names can cause incorrect ordering:
File name List of new names
One.txt First.txt
Two.txt Third.txt
Three.txt Fourth.txt
Four.txt Fifth.txt
Reformat Date Rule
This rule allows finding and reformatting various date/time values in the filename.
Allowed date/time format variables are described in the Date and Time format article.
Reformat Date Rule 45
Parameter Description
Find date/time format Find date and/or time matching a specified format.
A dropdown menu provides a quick access to commonly used formats.
Convert to date/time
format
Convert found date and/or time values to the specified format.
A dropdown menu provides a quick access to commonly used formats.
Match as whole words
only
When searching for a matching date/time pattern, match only if the found pattern is a whole word, i.e. surrounded by
word boundaries.
For example: A 4 digit year pattern (YYYY) will be found in "foo1234bar" if this option is disabled, but not found if
option is enabled.
Skip extension Exclude file extension from processing.
Use custom short
months
Use a custom list of short month names when searching or formatting short month name pattern (MMM). Month names
are separated by a comma.
By default, month names from the system locale are used.
Use custom long
months
Use a custom list of long month names when searching or formatting long month name pattern (MMMM). Month names
are separated by a comma.
By default, month names from the system locale are used.
46
Pascal Script
Pascal Script
The PascalScript Rule in ReNamer uses Pascal Script component to allow users to program their own renaming rule.
To master Pascal Script, follow these steps:
1.
1. Learn the basic syntax and concepts of Pascal Script
2.
2. Understand the specific variables, procedures and functions that are defined within ReNamer
3.
3. Learn how to use these variables/functions/procedures in scripts
Let us see these steps in more details.
Learn the basics
To learn the basics of Pascal Script, please refer to the Pascal Script Quick Guide.
Types and functions
In this section, we will see all types, procedures and functions which can be used within ReNamer.
•
• Types
•
• Procedures and functions
Note: Most of these are not part of the "standard" Pascal Script, so you may not find them in other applications.
Script cookbook
In this section, we will see how to write scripts for some common renaming tasks.
They also demonstrate how to use ReNamer's types, procedures and functions.
1.
1. How to rename a file (using the FileName variable)
2.
2. How to skip extention (basic FileName utilities)
3.
3. How to convert the filename to ALLCAPS (the WideUpperCase function)
4.
4. How to operate on words (Unicode string-handling routines)
5.
5. How to serialize files (basic conversion routines)
6.
6. How to initialize variables
7.
7. How to create interactive dialogs
8.
8. How to work with folders and paths (FilePath constant)
9.
9. How to break the script execution
10.
10. How to read file content
11.
11. How to import functions
12.
12. How to split file path into parts (folders, base, extension)
13.
13. How to store/load variables for later reuse
Pascal Script 47
Scripts repository
• Official Scripts Repository.
• The Forum
[1]
contains several ready scripts.
Study them and adopt them for your purpose.
Tips
A few quick tips:
• In Pascal Script, ReNamer has defined the FileName variable to represent the "New Name" of a file. Therefore,
in your script, you will have to manipulate this variable to change the filename. Changes to the FileName variable
do not actually change the name of the file, they simply change the value in the "New Name" column. Changes
are applied only when you click the "Rename" button.
• The FilePath constant holds the original path of the file. It allows you to access the file directly.
• ReNamer supports User Defined Functions (UDF) and also importing of external functions from DLLs.
• Try to use WideString type instead of an ordinary String type. This will allow ReNamer to handle Unicode
filenames. In other words, it will be able to handle non-English scripts, such as Cyrillic, Asian, German, French,
etc.
• You may use {$INCLUDE 'filename.inc'} directive to include code from an external file, allowing for
easier reuse and better organization of your code. Available since v6.5.0.1 Beta.
Warnings:
•
• Do not override ReNamer's built-in variables, types and functions.
•
• Some functions are able to alter your file system, e.g. create new folders, change file content, delete files, etc. Use
such functions with caution! Remember that scripts are executed during Preview (not Rename) operation and they
can be get executed automatically if Auto Preview is enabled.
External links
• RemObjects Pascal Script
[1]
Developers of the Pascal Script component.
• Delphi Basics
[2]
Help and reference for the fundamentals of the Delphi/Pascal language.
References
[1] http://www.remobjects.com/ps
[2] http://www.delphibasics.co.uk/
Quick Guide 48
Quick Guide
If you are not familiar with Pascal Scripting, first go through the excellent tutorial
[1]
written by Tao Yue.
The following is a short overview of Pascal Script.
Basic pascal script
The structure of a basic script is as follows (keywords are shown in ALLCAPS bold):
CONST
<Constant declarations>
TYPE
<Type declarations>
VAR
<Variable declarations>
BEGIN
<Executable statements>
END.
Note that:
• The main code must be within the begin and end. keywords.
• All statements in the script use the semicolon ";" as terminator. Only the last statement (END.) uses a dot as
terminator.
Control structures
All the typical control structures (building blocks) occurring in Pascal Script are described in the following table.
The table shows a flow chart and Pascal Script code required to implement that logic. To compose your own
PascalScript rule, you can simply copy and paste the code and then edit it to finish your script.
In actual implementation, just substitute the following:
• Replace <Condition> with an actual Pascal statement that tests for a condition.
• Replace <Action> with code block that takes action relevant to the condition. There may be several statements.
Branching
These structures are used to execute different blocks of code depending upon a condition.
Quick Guide 49
Branching
structure
Pascal script Flowchart (Logic) Remarks
if-then if <Condition> then
begin
<Action>
end;
Execute the <Action> statement only if the
<Condition> is met. Otherwise pass on the
control to the next statement that follows the
<Action>.
if-then-else if <Condition> then
begin
<Action-1>
end else
begin
<Action-2>
end;
Two alternative actions are provided.
If <Condition> is met, execute <Action-1>.
Otherwise execute <Action-2>.
Thus one of these two <Actions> are definitely
executed.
After execution of the action, pass on the control
to the next statement.
case/switch case X of
1:
begin
<Action-1>
end;
2:
begin
<Action-2>
end;
else
begin
<Default Action>
end;
end;
This code structure has several <Action> blocks,
each with its own condition.
• Any given <Action> block is executed only if
its condition is met.
• One and only one <Action> is executed. After
that, the control passes on to the next
statement. (It does not check for the next
condition.)
• The conditions are checked in the "top down"
order. So even if the other conditions are also
met, their <Actions> will never be executed.
• The code structure can optionally have a
<Default Action>. It is executed if (and only
if-) none of the conditions are met.
This is a generalized version of the if-then-else
block (above).
Quick Guide 50
Loops
Loops are used to execute a block of code iteratively till a certain condition is met.
Loops Pascal script Flowchart (Logic) Remarks
For To
Do
for I := X to Y do
begin
<Action>
end;
Execute the <Action> a certain number of
times. This example shows that the counter is
incremented by 1, but it can be any statement
that changes the value of the counter vaiable
towards the target value.
Similarly, the decision block can have any
logical expression with the counter.
Make sure that the exit condition is reached at
some point of time; otherwise the loop will
execute endlessly, and ReNamer will appear to
be hung.
While Do while <Condition> do
begin
<Action>
end;
Check for a condition and if it is met, execute
the <Action>. The loop is repeated till the
condition is met. When the condition is not
met, the loop is terminated and control passes
to the next statement. Note that if the condition
fails in the first-ever check, the <Action> may
not be executed at all.
Make sure that the condition will fail at some
point of time; otherwise the loop will execute
endlessly, and ReNamer will appear to be
hung.
Sometimes the condition is set to be always
TRUE, and then a statement inside the
<Action> block breaks the loop based on a
different condition.(See the break command
below)
Repeat
Until
repeat
<Action>
until <Condition>;
This structure is similar to the While loop (see
above). However, the only difference is that
the <Action> is taken first and then the
condition is checked. As a result, the
<Action> is executed at least once.
Quick Guide 51
Break Break;
OR
if <Condition> then Break;
This statement is placed in any of the above loops to terminate the loop when a condition
is met. Typically, it is used as the <Action> statement in a if-then block. This block is
then embedded (nested) inside the other code block that is to be contionally terminated.
See the Case block above, which uses the break statement as integral part of its structure.
Continue Continue;
OR
if <Condition> then Continue;
This statement is placed in any of the above loops to jump to the end of the current
iteration, bypassing all the subsequent statements within the loop. However, the execution
of the loop continues (the next iteration starts).
Typically, it is used as the <Action> statement in a if-then block. This block is then
embedded (nested) inside the other code block, just before the statements that are to be
skipped in the current iteration.
Control
Exit Exit;
OR
if <Condition> then Exit;
The Exit procedure abruptly terminates the current function or procedure. If exiting a function, then
Result contains the last set value.
Warning: use with caution - jumping is a concept at odds with structured coding - it makes code
maintenance difficult.
References
[1] http://www.taoyue.com/tutorials/pascal/contents.html
Types
This page lists and explains all supported types in Pascal Script used within ReNamer.
Integer types
Type Size Lowest Value Highest Value
Byte 1 byte 0 255
ShortInt 1 byte -128 127
Word 2 bytes 0 65,535
SmallInt 2 bytes -32,768 32,767
Cardinal 4 bytes 0 4,294,967,295
Integer 4 bytes -2,147,483,648 2,147,483,647
Int64 8 bytes -9,223,372,036,854,775,808 9,223,372,036,854,775,807
Floating point types
Types 52
Type Size Range
Single 4 bytes
1.5 x 10
-45
.. 3.4 x 10
38
Double 8 bytes
5.0 x 10
-324
.. 1.7 x 10
308
Extended 10 bytes
3.6 x 10
-4951
.. 1.1 x 10
4932
String types
Type Description
Char Stores a single Ansi character.
String Holds a sequence of Ansi characters of any length.
AnsiChar Alias for Char type.
AnsiString Alias for String type.
WideChar Stores a single Unicode character.
WideString Holds a sequence of Unicode characters of any length.
Note: Unicode article highlights the difference between Unicode and Ansi.
Mixed types
Type Description
Boolean Provides an enumeration of the logical True and False values.
Array Single and multi dimensional indexable sequences of data.
Record Provides means of collecting together a set of different data types into one named structure.
Variant Provides a flexible general purpose data type.
PChar Pointer to a Char value, and can also be used to point to characters within a string.
Extra types
Several extra types have been defined to simplify the use of some functions.
Type Declared as Description
TDateTime Double Holds date and time
TStringsArray Array of WideString Holds an indexable sequence of WideString.
Deprecated in v5.74.4 Beta. Please use TWideStringArray instead.
TWideStringArray Array of WideString Holds an indexable sequence of WideString.
Added in v5.74.4 Beta. Replaces ambiguous TStringsArray type.
TAnsiStringArray Array of AnsiString Holds an indexable sequence of AnsiString.
Added in v5.74.4 Beta.
Types 53
Enumerations and Sets
For example, the Boolean data type is itself an enumeration, with two possible values: True and False. If you try to
assign a different value to a Boolean variable, the code will not compile.
Example Description
type
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
var
Day: TDay;
begin
Day := Mon;
if Day <> Tue then
Day := Wed;
end.
An enumeration is simply a fixed range of named values
type
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
TDays = set of TDay;
var
Days: TDays;
begin
Days := [Mon, Tue, Wed];
if Sun in Days then
Days := Days - [Sun];
end.
Whereas enumerations allow a variable to have one, and only one, value from
a fixed number of values, sets allow you to have any combination of the given
values
Functions
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for
individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file,
strings entered by the user, etc. This functionality is available for use via the PascalScript rule.
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a
value, a procedure just executes an algorithm without returning anything.
A common prefix Wide in the function name indicates that the function deals with Unicode strings (WideString).
ReNamer has similar functions without Wide prefix, for processing ANSI strings. For example, ShowMessage and
WideShowMessage procedures.
Basic String Handling
Functions 54
Routine Remarks
procedure Insert(Source: String; var S: String; Index:
Integer);
Inserts the string S into string Source at position Index.
procedure Delete(var S: String; Index, Count: Integer); Deletes Count characters from the string S, starting from position Index.
function Copy(S: String; Index, Count: Integer): String; Copies Count characters from string S, starting at position Index, and returns them as a
new string.
function Pos(Substr: String; S: String): Integer; Returns the position of a string Substr in another string S.
Note: Indexes of characters in strings are 1 based, so first character in string S would be S[1].
Length Management
Routine Remarks
procedure SetLength(var S: Array; NewLength: Integer); Sets the length of array variable S to NewLength.
procedure SetLength(var S: String; NewLength: Integer); Sets the length of string variable S to NewLength.
procedure SetLength(var S: WideString; NewLength: Integer); Sets the length of widestring S to NewLength.
function Length(const S: Array): Integer; Returns the length of array S (number of elements).
function Length(const S: String): Integer; Returns the length of string S (number of characters).
function Length(const S: WideString): Integer; Returns the length of WideString S (number of characters).
Unicode String Handling
Routine Remarks
procedure WideInsert(const Substr:
WideString; var Dest: WideString; Index:
Integer);
Inserts Substr in Dest at position Index.
procedure WideDelete(var S: WideString;
Index, Count: Integer);
Deletes Count characters from S, starting from the Index position.
procedure WideDeleteRight(var S:
WideString; Index, Count: Integer);
Delete Count characters from S, starting from the Index position from the end and counting
towards the start.
Added in v6.0.0.9 Alpha.
procedure WideSetLength(var S: WideString;
NewLength: Integer);
Change the length of string S to a new length specified by NewLength. If new length is smaller
than original, the string is truncated. If new length is greater than original, the string will be
expanded but additional characters will not be initialized and can be anything.
function WideLength(const S: WideString):
Integer;
Returns the length of WideString S.
function WideCopy(const S: WideString;
Index, Count: Integer): WideString;
Returns Count characters from S, starting at position Index. (Index is zero based)
Example: myVarFirst4Signs:=WideCopy(FileName,0,4);
function WideCopyRight(const S:
WideString; Index, Count: Integer):
WideString;
Returns Count characters from S, starting at position Index from the end and counting towards the
start.
Added in v6.0.0.9 Alpha.
function WidePos(const SubStr, S:
WideString): Integer;
Find and occurrence of SubStr in S. Returns the position of first occurrence, or 0 if nothing was
found.
function WidePosEx(const SubStr, S:
WideString; Offset: Cardinal): Integer;
Find and occurrence of SubStr in S but start searching from position specified by Offset. Returns
the position of first occurrence, or 0 if nothing was found.
Functions 55
function WideUpperCase(const S:
WideString): WideString;
Returns the ALLCAPS version of the WideString S
function WideLowerCase(const S:
WideString): WideString;
Returns the lowercase version of the WideString S
function WideCompareStr(const S1, S2:
WideString): Integer;
Compares two WideStrings S1 and S2, case-sensitive, and returns an integer based on the result.
The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is
greater than S2.
function WideCompareText(const S1, S2:
WideString): Integer;
Compares two WideStrings S1 and S2, case-insensitive, and returns an integer based on the result.
The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is
greater than S2.
function WideSameText(const S1, S2:
WideString): Boolean;
Compares two WideStrings S1 and S2, case-insensitive. Returns TRUE if both are identical,
otherwise returns FALSE.
function WideTextPos(const SubStr, S:
WideString): Integer;
Behaves like WidePos function, except text if processed in case-insensitive manner.
function WideTextPosEx(const SubStr, S:
WideString; Offset: Cardinal): Integer;
Behaves like WidePosEx function, except text if processed in case-insensitive manner.
Added in v6.6.0.1 Beta.
function WideTrim(const S: WideString):
WideString;
Removes leading and trailing spaces and control characters from the given string S.
function WideTrimChars(const S,
CharsToTrim: WideString): WideString;
Remove characters that occur in CharsToTrim from the beginning and the end of S.
Added in v6.0.0.9 Alpha.
function WideTrimCharsLeft(const S,
CharsToTrim: WideString): WideString;
Remove characters that occur in CharsToTrim from the beginning of S.
Added in v6.0.0.9 Alpha.
function WideTrimCharsRight(const S,
CharsToTrim: WideString): WideString;
Remove characters that occur in CharsToTrim from the end of S.
Added in v6.0.0.9 Alpha.
function WideReverseString(const S:
WideString): WideString;
Return a reversed version of string S, i.e. reverse the order of characters.
Added in v6.7.0.4 Beta.
function WideRepeatString(const S:
WideString; Count: Integer): WideString;
Repeat a string a number of times.
Added in v6.9.0.3 Beta.
function WideReplaceStr(const S, OldPattern,
NewPattern: WideString): WideString;
Return a result of a case-sensitive replacement of all occurrences of OldPattern with NewPattern
in a string S.
function WideReplaceText(const S,
OldPattern, NewPattern: WideString):
WideString;
Return a result of a case-insensitive replacement of all occurrences of OldPattern with
NewPattern in a string S.
function WideSplitString(const Input,
Delimiter: WideString): TWideStringArray;
Splits the Input wherever Delimiter occurs and returns an array that contains the split parts.
• The Delimiter itself can be a multi-character WideString.
(Unlike the usual comma, hyphen or space that are used for this purpose)
• The split parts (returned as elements of the array) do not contain the Delimiter.
function WideJoinStrings(const Strings:
TWideStringArray; const Delimiter:
WideString): WideString;
Joins all individual items from Strings into a single WideString, with Delimiter inserted between
the joined items.
function WideCaseSentence(const S:
WideString): WideString;
Returns a Sentence case version of parameter S.
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to
lowercase.
Added in v6.0.0.3 Alpha.
function WideCaseCapitalize(const S:
WideString): WideString;
Returns the Title case version of parameter S.
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.
Functions 56
function WideCaseInvert(const S:
WideString): WideString;
Inverts case of all characters in S and returns it.
Unicode Character Handling
Function Remarks
function IsWideCharUpper(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is in UPPERCASE.
function IsWideCharLower(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is in lowercase.
function IsWideCharDigit(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a digit (numeric character
0-9).
function IsWideCharSpace(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a white-space character,
such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters
classified as C1_SPACE).
function IsWideCharPunct(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a punctuation mark
(characters classified as C1_PUNCT).
function IsWideCharCntrl(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a control character
(characters classified as C1_CNTRL).
function IsWideCharBlank(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a blank, such as: space
and tab (characters classified as C1_BLANK).
function IsWideCharXDigit(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a hexadecimal digit (0-9
or A-F).
function IsWideCharAlpha(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a alphanumeric character
(a-z or A-Z).
function IsWideCharAlphaNumeric(WC: WideChar):
Boolean;
Checks a Unicode character WC and returns TRUE if it is a alphanumeric character
or a numeric character (a-z, A-Z or 0-9).
function IsWideWordBoundaryLeft(const Subject:
WideString; CharPosition: Integer): Boolean;
Check if a character at the specified position is on a word boundary to the left.
Conditions that qualify as word boundaries to the left of character:
1.
1. If first character and is a word character.
2.
2. Between word and not a word character.
Added in v6.6.0.1 Beta.
function IsWideWordBoundaryRight(const Subject:
WideString; CharPosition: Integer): Boolean;
Check if a character at the specified position is on a word boundary to the right.
Conditions that qualify as word boundaries to the right of character:
1.
1. If last character and is a word character.
2.
2. Between word and not a word character.
Added in v6.6.0.1 Beta.
function WideCharUpper(const WC: WideChar):
WideChar;
Returns a UPPERCASE version of the input Unicode character. In case of
non-alphabetic character, it returns the same character.
function WideCharLower(const WC: WideChar):
WideChar;
Returns a lowercase version of the input Unicode character. In case of
non-alphabetic character, it returns the same character.
function WideChr(Code: Word): WideChar; Create a Unicode character from a code point.
Added in v6.9.0.3 Beta.
Note: Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT,
C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding
classification can be found on the internet. For example: http://www.fileformat.info/info/unicode/
[1]
.
Functions 57
Unicode Conversion
Function Remarks
function WideToAnsi(const WS: WideString):
String;
Converts a Unicode string to its ANSI version.
function AnsiToWide(const S: String):
WideString;
Converts a ANSI string to its Unicode version.
function UTF8Encode(const WS:
WideString): String;
Convert Unicode string to the UTF-8
[2]
encoded string.
Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to
reduce the size of the file.
function UTF8Decode(const S: String):
WideString;
Convert UTF-8
[2]
encoded string to its full Unicode representation.
Console Output Conversion
OEM-defined character set is commonly used in the output of console applications.
Function Remarks
function OemToAnsi(const S: String): String; Convert OEM string into an ANSI
string.
Added in v6.6.0.2 Beta.
function OemToWide(const S: String): WideString; Convert OEM string into a WideString.
Added in v6.6.0.2 Beta.
function AnsiToOem(const S: String): String; Convert ANSI string into an OEM
string.
Added in v6.6.0.2 Beta.
function WideToOem(const S: WideString): String; Convert WideString into an OEM string.
Added in v6.6.0.2 Beta.
Basic Conversion
Function Remarks
function BoolToStr(B: Boolean):
String;
Convert boolean variable into a string. Returns "True" or "False" string value.
function IntToStr(Value: Integer):
String;
Converts an integer to a string. The following assumptions are correct:
•
• IntToStr(123) = '123'
•
• IntToStr(0123) = '123'
• IntToStr(123) <> '0123'
Note: Be cautious of supplying Int64 type as a parameter as it will be type casted to Integer, which
significantly reduces the range of possible values (refer to Types for more information). You can use
FormatFloat function to convert Int64 values to a string without a loss of range.
function Int64ToStr(Value: Int64):
String;
Same as IntToStr but takes in Int64 typed parameter.
function StrToInt(const S: String):
Integer;
Converts a string to an integer. The following equalities are correct:
•
• StrToInt('123') = 123
•
• StrToInt('123') = 0123
•
• StrToInt('0123') = 123
Warning: An error will occur if the parameter to this function cannot be converted to an integer!
Functions 58
function StrToInt64(const S: String):
Int64;
Same as StrToInt but returns Int64 typed result.
function StrToIntDef(const S: String;
const Default: Integer): Integer;
Behaves like StrToInt function, but instead of producing an error on incorrect input function allows the
Default value to be specified, which will be returned if the input cannot be converted to an integer.
function StrToInt64Def(const S:
String; Default: Int64): Int64;
Same as StrToIntDef but operates with Int64 type.
function TryStrToInt(const S: String;
out Value: Integer): Boolean;
Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike
StrToInt. Returns False if conversion operation has failed.
function FloatToStr(Value: Extended):
string;
Converts supplied floating point value to its string representation, using default system format.
function StrToFloat(const S: string):
Extended;
Converts supplied string to a floating point value.
Warning: An error will occur if the parameter to this function cannot be converted to a floating point
value!
function StrToFloatDef(const S:
string; const Default: Extended):
Extended;
Behaves like StrToFloat function, but instead of producing an error on incorrect input function allows the
Default value to be specified, which will be returned if the input cannot be converted to a floating point
value.
function FormatFloat(const Format:
string; Value: Extended): string;
Converts supplied floating point value to its string representation, using user specific Format.
Check floating point format specifiers below for more information.
function DateToStr(D: TDateTime):
String;
Converts a date to a string, using system format for the short date, for example: dd/mm/yyyy.
function StrToDate(const S: String):
TDateTime;
Converts a date string to a proper TDateTime value, using system format for the short date, for example:
dd/mm/yyyy.
function IntToHex(Value: Integer;
Digits: Integer): String;
Converts an integer to its hexadecimal representation. Here are samples:
•
• IntToHex(1234, 1) = '4D2'
•
• IntToHex(1234, 8) = '000004D2'
function HexToInt(const HexNum:
String): Integer;
Converts a hexadecimal value to its decimal representation.
Warning: An error will occur if the parameter to this function cannot be converted to an integer!
function HexToIntDef(const HexNum:
String; Default: Integer): Integer;
Behaves like HexToInt function, but instead of producing an error on incorrect input function allows the
Default value to be specified, which will be returned if the input cannot be converted to an integer.
function Ord(X: Char): Byte; Return an ordinal value (byte representation) of a character.
function Chr(X: Byte): Char; Return a character by its ordinal value (byte representation).
Floating point format specifiers
Specifier Represents
0 (zero) Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is
copied to the output string. Otherwise, a "0" is stored in that position in the output string.
# (hash) Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is
copied to the output string. Otherwise, nothing is stored in that position in the output string.
. (dot) Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any
additional "." characters are ignored.
, (comma) Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between
each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not
affect the output.
Functions 59
Date and Time
Function Remarks
function Date: TDateTime; Returns the current system date.
function Time: TDateTime; Returns the current system time.
function Now: TDateTime; Returns the current system date and time.
function EncodeDate(Year, Month, Day: Word):
TDateTime;
Generates date value for the specified Year, Month, Day. Parameters must be within a
valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on
month/year). An error will be raised if parameters are invalid.
function EncodeTime(Hour, Min, Sec, MSec: Word):
TDateTime;
Generates time value for the specified Hour, Min, Sec, MSec. Parameters must be
within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An
error will be raised if parameters are invalid.
function EncodeDateTime(Year, Month, Day, Hour,
Minute, Second, MilliSecond: Word): TDateTime;
Generates date-time value for the specified components of date and time. Similar to
EncodeDate and EncodeTime.
Added in v6.2.0.5 Beta.
function TryEncodeDate(Year, Month, Day: Word; var
Date: TDateTime): Boolean;
Behaves exactly like EncodeDate function, except this function returns TRUE or
FALSE depending on the success of the operation. If operation was successful, function
will return TRUE and the generated date value will be written in the Date variable.
function TryEncodeTime(Hour, Min, Sec, MSec: Word;
var Time: TDateTime): Boolean;
Behaves exactly like EncodeTime function, except this function returns TRUE or
FALSE depending on the success of the operation. If operation was successful, function
will return TRUE and the generated time value will be written in the Time variable.
function TryEncodeDateTime(Year, Month, Day, Hour,
Minute, Second, MilliSecond: Word; out ADateTime:
TDateTime): Boolean;
Behaves exactly like EncodeDateTime function, except this function returns TRUE or
FALSE depending on the success of the operation. If operation was successful, function
will return TRUE and the generated date-time value will be written in the ADateTime
variable.
Added in v6.2.0.5 Beta.
procedure DecodeDate(const DateTime: TDateTime; var
Year, Month, Day: Word);
Extracts Year, Month and Day components from a given DateTime value.
procedure DecodeTime(const DateTime: TDateTime; var
Hour, Min, Sec, MSec: Word);
Extracts Hour, Min, Sec and MSec components from a given DateTime value.
procedure DecodeDateTime(const DateTime:
TDateTime; out Year, Month, Day, Hour, Minute,
Second, MilliSecond: Word);
Similar to DecodeDate and DecodeTime but extracts both date and time components at
once.
Added in v6.2.0.5 Beta.
function ComposeDateTime(const Date, Time:
TDateTime): TDateTime;
Combine date and time components into a single date-time value.
Added in v6.2.0.5 Beta.
function DateTimeToUnix(D: TDateTime): Int64; Converts D value of type TDateTime to a Unix timestamp.
function UnixToDateTime(U: Int64): TDateTime; Converts a Unix timestamp to a value of TDateTime type.
function FormatDateTime(const Fmt: String; D:
TDateTime): String;
This function provides rich formatting of a DateTime value into a string. Date and time
format is defined by the Fmt string.
function IncYear(const AValue: TDateTime; const
ANumberOfYears: Integer): TDateTime;
Increments a TDateTime variable by a number of years (plus or minus).
function IncMonth(const AValue: TDateTime;
ANumberOfMonths: Integer): TDateTime;
Increments a TDateTime variable by a number of months (plus or minus).
function IncWeek(const AValue: TDateTime; const
ANumberOfWeeks: Integer): TDateTime;
Increments a TDateTime variable by a number of weeks (plus or minus).
function IncDay(const AValue: TDateTime; const
ANumberOfDays: Integer): TDateTime;
Increments a TDateTime variable by a number of days (plus or minus).
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇
202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇

More Related Content

202554.com香蕉影视全网最高清,最新电影,最新电视剧,在线观看狐妖小红娘月红篇

  • 1. PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Thu, 31 Jan 2019 23:32:55 CET ReNamer User Manual www.den4b.com
  • 2. Contents Articles Basics 1 ReNamer 1 Introduction 2 Quick Guide 3 Step-by-step 4 Adding files and folders 4 Managing Rules 8 Previewing Files 11 Renaming Files 12 Rules 14 Using the Rules 14 Overview of Rules 14 Insert Rule 15 Delete Rule 17 Remove Rule 18 Replace Rule 20 Rearrange Rule 22 Extension Rule 24 Strip Rule 25 Case Rule 26 Serialize Rule 28 Randomize Rule 30 Clean Up Rule 31 Translit Rule 33 Regular Expressions Rule 37 Pascal Script Rule 39 User Input Rule 42 Reformat Date Rule 44 Pascal Script 46 Pascal Script 46 Quick Guide 48
  • 3. Types 51 Functions 53 User Scripts 69 Appendices 71 Using Presets 71 Manual Editing 77 Analyze 79 Program settings 80 Main Menu and Keyboard Shortcuts 86 Menus for the Files Pane 88 Context Menus 95 Date and Time Format 97 Binary Signatures 98 Meta Tags 101 Analyze 102 Regular Expressions 104 Command Line Mode 111 Sorting Files 114 Using Masks 115 Renaming Folders 116 Renaming to Another Folder 117 Failed Renaming 118 Validation of New Names 119 Examples of rules 119 Examples of Rearrange rule 121 References Article Sources and Contributors 134 Image Sources, Licenses and Contributors 136 Article Licenses License 138
  • 4. 1 Basics ReNamer ReNamer is a very powerful and flexible file renaming tool. ReNamer offers all the standard renaming procedures, including prefixes, suffixes, replacements, case changes, removing the content inside brackets, adding number sequences, changing file extensions, etc. Advanced users can program their own algorithm using PascalScript rule. ReNamer allows you to combine multiple renaming actions as a rule set, which can be saved, re-loaded, and edited. In addition, it can rename folders and process regular expressions. It can handle Unicode (non-English scripts). ReNamer supports a variety of meta tags, such as: ID3v1 [1] , ID3v2 [1] , EXIF [2] , OLE [3] , AVI [4] , MD5 [5] , CRC32 [6] , SHA1 [7] and many more. References [1] http://en.wikipedia.org/wiki/ID3 [2] http://en.wikipedia.org/wiki/EXIF [3] http://en.wikipedia.org/wiki/Object_Linking_and_Embedding [4] http://msdn.microsoft.com/en-us/library/ms779636.aspx [5] http://en.wikipedia.org/wiki/MD5 [6] http://en.wikipedia.org/wiki/CRC32 [7] http://en.wikipedia.org/wiki/SHA1
  • 5. Introduction 2 Introduction ReNamer is a very powerful and flexible file renaming tool with the following features: • The workflow toolbar makes renaming easy. • ReNamer can rename files belonging to different folders (or even different computers) at a time. You can also filter the contents of the folders before renaming. • ReNamer offers extensive set of rules for renaming. Each rule has controllable parameters. • • ReNamer can stack multiple rules in any sequence and apply in that order. • ReNamer provides full preview (the affected file names can be highlighted). • ReNamer allows you to try out the stack of rules on user-defined text (this allows safe experimentation, without risking real files). • • ReNamer can automatically handle name-conflicts arising from the renaming. • You can save the stack of rules as a "preset" and re-use it later with a keyboard shortcut. • ReNamer can rename folders. • ReNamer can move files to other folders. • • ReNamer can rename Windows network (neighbourhood) files also. • ReNamer can use RegEx (Regular Expressions) for the renaming. • • ReNamer supports Unicode filenames (e.g. Asian scripts, Cyrillic, French, Spanish, Arabic, Hebrew, etc). • ReNamer allows scripting (Pascal Script) to create complex renaming logic. (many scripts are available on the Forum [1] ). • ReNamer can extract a large variety of meta tags from files and use them for the renaming. (e.g. ID3v1 [2] , ID3v2 [3] , EXIF [4] , OLE [3] , AVI [4] , MD5 [5] , SHA1 [5] , CRC32 [6] , etc) • • ReNamer can export/import the renaming-related information. • ReNamer can take automatic actions based on outcome of renaming operation (e.g. clear off all successfully renamed files from the pane, but retain the problematic files) • ReNamer can be run in command line mode, with lots of parameters. This allows you to select your files in explorer (or any other application) and do one-touch renaming.
  • 6. Introduction 3 References [1] http://www.den4b.com/forum/ [2] http://www.id3.org/ID3v1 [3] http://www.id3.org/ [4] http://exif.org [5] http://en.wikipedia.org/wiki/Sha1 [6] http://en.wikipedia.org/wiki/Crc32 Quick Guide The ReNamer interface is shown below. Click on any part of the screenshot to see full description. Using ReNamer is very simple. Just follow the four steps shown below. Step What to do 1 Select the files from various folders and add them to the working area. a. Change the default behavior for the "Add Folders" button (optional step). b. Add individually selected files (Add Files) and/or all files in selected folders (Add Folders), and/or... c. c. Drag-n-drop files from Windows Explorer (or any other application) into this area (called "Files pane"). 2 Add rules to create a sequence of operations. Delete or edit an existing rule. Change the order of the rules. a. Allows addition and deletion of rules. Also change the order of any rule in the stack. b. b. Click in this area to add a rule (or to edit an existing rule, or just move it to a new position in the list). 3 Preview the results (check before proceeding with the actual renaming). a. Set options (e.g. highlight changed names, experiment with your own text, resolve conflicts, etc.). b. Click to see preview of the new file names in the bottom pane (not required in auto-preview mode). 4 Press this button to rename files and folders. ReNamer is so intuitive that you would be able to use it without reading the manual any further.
  • 7. Quick Guide 4 The rest of the chapters provide more details on all aspects of ReNamer. Use them as reference. There is an older version of this guide available here: Quick Start. Step-by-step As discussed before in the Quick Guide, ReNamer is used in just four steps, which are explained in this section (follow the links): 1. Load the files and/or folders to be renamed. 2. Load the renaming rules in a stack. 3. Preview the renamed files/folders to check if the result is as expected. 4. Rename the files/folders. Adding files and folders In this section, we will see how to place files and folders in ReNamer's working area (also called the Files pane). This consists of: 1. 1. Adding files and folders, 2. 2. Removing some files from the pane, and 3. 3. Changing the order of files in the pane. ReNamer has multiple methods for these actions, as described below
  • 8. Adding files and folders 5 Adding files using the 'Add Files' button 1. Press the button. The following window pops up: 2. Navigate to the required folder and select files. 3. Press OK. The selected files are added to ReNamer's Files pane. 4. 4. Repeat steps 1-3 to load files from other folders (as required).
  • 9. Adding files and folders 6 Adding items using the 'Add Folders' button 1. To add all the files belonging to a folder, press the button. The following window pops up: • When you select a node in the tree, all its sub-nodes are automatically selected. In other words, when you select a folder, its subfolders are automatically selected. • By default, ReNamer adds all files from a folder, but not the folder itself. So if you want to rename the folder itself (and not its contents), then select this option using the Filters. • • You can select any node from the tree. That means you can even select any/all drives on your computer! • You can select multiple nodes at a time, by pressing CTRL first and then cliking on different nodes of the tree. All those nodes will be added at one stroke. 2. If you want to add only certain items from the selected folder, set ReNamer's Filters by clicking on the "Filter Settings" button and then selecting different options. Depending on your selected options in this window, the Add folders window will add different items to ReNamer's Files pane. • You can also set the filters by clicking the "Filters" button (located above the Files pane) 3. 3. Navigate to the desired folder and press the "Add Folders" button.
  • 10. Adding files and folders 7 Adding files using the Drag-and-drop method Select the files in any application and drag-and-drop them into ReNamer's Files pane. • To drag-and-drop, click on your file selection with LMB. Without releasing the LMB, start moving the mouse. Now bring the mouse pointer over the ReNamer's Files pane, and then release the LMB. • If the ReNamer's window is not visible, first drag your selection onto ReNamer's task button in Windows Taskbar (normally located at the bottom of your desktop). Wait for a couple of seconds without releasing the LMB. The ReNamer window pops up, and stays above other applications' windows on your screen. Now you can move your mouse over the ReNamer window and drop your selection of files. • You can also configure ReNamer to stay on top of all other windows, so even when you are working in the other applications ReNamer will remain on top of other windows. Adding files using the copy-and-paste method Select the files in any application and press CTRL+C to copy them into the clipboard. Now switch to ReNamer and press SHIFT+CTRL+V. Note that: • Renamer does not use the usual keyboard shortcut CTRL+V. • It is not necessary to click inside the Files pane for the paste operation. Removing files or folders from pane If you have added more files by mistake, you can remove them easily in just two steps: 1. Select the items 2. Press the DEL key. (This only removes the files/folders from the ReNamer. It does not delete them from the disk!) Changing the order of the files in the pane Certain rules (e.g. the Serialize Rule) act on the list of the files in "from-top-to-bottom" order (as opposed to acting on each file independently). In such cases, each file gets its name based on its position in the list. (For example, the nth file in the list is named Track-n.mp3.) Normally, the files are listed in the order you added them to the pane (the most recently added file goes to the bottom of the list). But you can change the position of the files in the list. Just click on the file and drag it to the new position. • You can select multiple files and drag all of them as a group to the new position. Sorting files in the files pane You can also sort files in the Files pane by any column with just a click on the column title. The little triangle will show up to indicate the order of sorting. For more information have a look at the full article on sorting files. Selecting files You can carry out various operations on selected files. To select one or more files: 1. 1. Click anywhere in the row except on the check box. • To select non-adjacent files, press CTRL and then click on individual rows.
  • 11. Adding files and folders 8 • To select files listed in adjacent rows, first click on the row at one end, then keep the SHIFT pressed down, and click on the row at the other end. 2. Draw a lasso (rectangle) with the mouse in the Files pane. All the rows touched by the rectangle are selected. • • If you repeat these actions on an item, they toggle the selection status (selected-unselected). When selecting only one row, use Up and Down arrow keys to change the selection to adjacent row. Marking and Unmarking the files A file is marked by putting a tick in its check box . Conversely, it is unmarked by removing the tick . ReNamer acts only on the marked files. An unmarked file is neither previewed nor renamed. So unmarking a file is useful to exempt a file from renaming, without having to remove it from the Files pane. To mark/unmark the files: 1. 1. Click on the check box. 2. Select the files and press the Spacebar (on keyboard) (Repeat of these actions on any item toggles its marked/unmarked status.) Note that the marked/unmarked status of a file has no relation with its selected/unselected status. Managing Rules This section explains how to add rules, remove rules, edit a rule and change the order in which they are applied to files and folders. Adding rules 1. 1. Rules can be added by using any of the following methods: • Click the button, • Click inside the Rules area, • Press the Ins key when the ReNamer window is active. 2. The Add Rule window pops up:
  • 12. Managing Rules 9 Select the desired rule. 3. The options for the selected rule appear immediately in the Configuration area (at right). Set the desired parameters, as explained in each rule. 4. Press the button at the bottom of the window. The rule is added to the stack and the window is closed. 5. 5. Repeat steps 1-5 to add more rules. Each new rule is added at the end of the stack. 6. 6. To close the window without adding a rule press the "Close" button (or the window close icon at the top right corner). Removing (deleting) rules To remove an existing rule, select it and press DEL or click on the button. Changing the order of the rules All rules are applied to each file in the order they appear. Even with the same set of rules, the end-result can be very different if the order of the rules is changed. You can change the order of rules using any of the following methods: 1. Using the and buttons. 2. Pressing CTRL + Up/Down arrows. 3. 3. Drag-and-drop any rule with mouse.
  • 13. Managing Rules 10 Editing rules Editing a rule means changing its parameters and options, and then saving the rule. You can edit a rule using any of the following methods: 1. 1. Double-click on it, 2. Right-click on it and select the Edit Rule option 3. Select it and press ENTER. A window similar to the Add Rules window appears. There are only two minor differences: the button at the bottom is titled Save Rule, and the rules list in the left pane is grayed out (because you are not supposed to select rules in this window). Change the parameters and options, and press the Save Rule button or ENTER. Selecting a rule When a rule is selected, its entire row is highlighted. Only one rule can be selected at a time. To select a rule, use any of the following methods: 1. 1. Click anywhere in the row except on the check box. 2. 2. Use the Up and Down arrow keys on your keyboard to move the selection to another rule. Marking and Unmarking a rule A rule is marked by putting a tick in its check box . Conversely, it is unmarked by removing the tick . ReNamer uses only the marked rules for the preview and renaming operations. So unmarking a rule is useful to temporarily disable the rule without having to remove it from the Rules pane. To mark/unmark the rules: 1. 1. Click on the check box. 2. Select a rule and press the Spacebar (on your keyboard) (Repeat of any of these actions toggles the marked/unmarked status.) The reasons for unmarking a rule are: 1. 1. You want to remove the effect of a rule and see what happens to the files. 2. 2. You have a favorite set of rules that you use often. However, you need to remove a few rules in some cases. A trick is to save the superset of rules and reload them automatically each time you start ReNamer. Then in each session, unmark some rules.
  • 14. Previewing Files 11 Previewing Files ReNamer shows a preview of the files, so that you can decide whether your rules are working as expected. If some files show unexpected results, edit some of the rules and check the preview again. Let us see how preview works. In the example below, there are three rules in the stack: 1. 1. Replaces "." "_" "%20" "-" with a space. 2. 2. Strips the contents of round brackets and removes unnecessary spacing. 3. 3. Capitalizes the first letter of the name and makes all other letters lowercase. The ReNamer preview is shown below. We can see that: • In the Files pane, the State column shows whether the renaming will face any problems. In this case, the green arrow identifies files that are ready to go, while files with potential problems are marked with a warning sign. • The New Name column shows a preview of the new names. If you have the Highlight changed names option enabled all changed names will be highlighted in red during preview. The first name is unchanged, so it is shown in black. The remaining names are affected by the rules, so they are shown in red. • The check boxes in the Rules pane allow you to disable any rule temporarily. (Disable one of the rules and see the effect on the renaming.) • The check boxes in the Files pane allow you to exempt any file/folder from the current renaming. New names are not shown for such unmarked files. There are many program options for previewing and preview process can vary based on those settings. For example, you can set it to refresh the preview automatically when new files and/or rules are added. You may also want to customize the columns displayed in the Files pane. For example, many users prefer to see the Path and New path columns.
  • 15. Previewing Files 12 • • To customize columns, right-click on the strip that contains all column-headers. A menu pops up all available columns. Select the columns you want. From now on, ReNamer remembers the new settings. Manual Preview mode If you do not select Automatic Preview mode, you must press the button to see the preview. This Manual Preview' mode is actually useful if you do not want to miss out the subtle changes that can happen to the file names when you are adding new rules or if you adjust the file names manually after preview. It can also save you a lot of time when processing large amount of files, so instead of generagin a preview on every change you can preview manually only when you need to. While using the Manual Preview mode, keep the following in mind: • Files will be renamed exactly as you see in the preview (WYSIWYG policy). Be sure to press the button after changing your rules, otherwise these changes will not be applied in the actual renaming! • If you change the items manually, these changes are lost if you press the button. Renaming Files When the button is pressed, the following happens: 1. The marked files are renamed according to the Name and New Name columns (or Path and New Path if changes affect the full path) in the Files pane. • If some of the rules do not seem to have applied, the reason could be that the ReNamer is in Manual Preview mode and you did not refresh the preview after adding/editing some of the rules. To update the preview, press the button again. • If your set of rules is not meant to move files from one folder to another, you can as well assume that files are renamed according to the Name and New Name columns of the Files pane. 2. The Name column now contains the new name of the item, and 3. The New Name column becomes empty • It is supposed to show a preview of the proposed new name, so once the file is renamed there is no new name any more. 4. Old names are remembered to allow reverting of the changes using the Undo Renaming option from the Main Menu. After the renaming is complete various additional actions can be performed based on Program settings for renaming. For example, the list of Rules and Files can be automatically cleared off, or program can automatically close. When is a file considered "renamed successfully"? Each renaming operation can have one of the following outcomes:
  • 16. Renaming Files 13 Outcome Is it considered as successfully renamed? A file that was unmarked (that is, was NOT marked for the current round of renaming) No A file name that was changed during the renaming operation. Yes A file name that did not change because none of the renaming rules were applicable. Yes A file name that caused error during renaming (e.g. invalid file name, name conflict, etc.) No You can set ReNamer's Program settings to take some conditional actions on the files based on their outcome. For example, you can clear off the files that were successfully renamed. Note: When the new name of the file is the same as the original name the renaming operation is still performed, but without any changes applied. It is important to note that such renaming operation can still fail, for example, because the original file no longer exists.
  • 17. 14 Rules Using the Rules You can load a stack of rules in ReNamer. These rules act on the loaded files in the "top-to-bottom" order. This allows you to achieve very complex renaming algorithms. • A rule modifies the name and then passes it to the next rule, which acts on the modified name (not the original name). • • Any rule can be used multiple times, each time with different settings. All you have to do is to visualize how each rule in the stack affects the file name when the file name "passes through" the stack. The first subtopic provides an overview of Rules. The subsequent subtopics show the specifics of each rule: • • How each option works, and how to set it. • • Examples (typical uses). Tip: If you are going to use the same set of rules frequently, it is best to save it as a Preset. This allows you to re-load the entire set with a keyboard shortcut (such as CTRL+1). A huge timesaver! Overview of Rules Overview of Rules ReNamer has an extensive set of rules. These rules can be combined together, in a logical sequence, to perform nearly any thinkable operation with the filename. You can also manually edit the name of any file. The table below lists all rules, with a brief description of each rule. The subsequent chapters provide more details for each rule (follow the links). Rules Description Insert Insert the specified text into the filename: as prefix, as suffix, at the specified position, before- or after the specified text. There is also an option to insert meta tags into the filename. Delete Delete a portion of the filename, usually defined by character positions: from the specified position, from the occurrence of the specified delimiter, until the specified number of characters, until occurrence of the specified delimiter or till the end. This rule can be set to process the filename in a right-to-left manner. Remove Remove the specified text from the filename: first, last or all occurrences. Optionally, wildcards can be used within this rule, to remove masked text fragments. Replace This rule is very much like the Remove rule (above). It has similar options, except that instead of removing the text fragments, it will replace them with the specified text. Rearrange Chop up the existing file name using any delimiter or position and reuse any/all of the parts in any order to compose a new name.Add your strings, or use the meta tags extracted from the file to compose the new name. Extension Change extension of files to the specified extension, or to the extension automatically detected through the internal database of binary signatures.
  • 18. Overview of Rules 15 Strip Strip all occurrences of the specified characters from the filename. This rule has predefined character sets, like digits, symbols, brackets, but you can also define your own character set. Case Change the case of the filename: capitalize each word, to lower case, to upper case, invert case, or capitalize only the first letter and force the rest to lowercase (as in a sentence). There is also an option to force case for the manually entered fragments, for example: CD, DVD, India, ReNamer, etc. Serialize Add incremental numbers to put filenames into an order. Randomize Add randomly generated sequences into filenames. CleanUp Cleanup filenames from (or for) commonly used naming conventions for Internet, peer-to-peer networks, and other resources. Translit Transliterate Non-English characters from different languages into their English/Latin representation. Useful for preparing files for network storage and transfer. Several transliteration maps are built in, and you can define your own maps. RegEx RegEx (=Regular Expressions) is used for complex pattern/expression matching and replacing operations. Although it may look complex at first, you can learn it quite easily, using the guide provided in this manual! PascalScript Scripting allows programming-aware users to code their own renaming rule using predefined set of functions. This rule uses Pascal/Delphi programming syntax and conventions. Extremely powerful feature in the right hands. UserInput Rule that simply sets the new names of the files to the names entered in a list (one name per line). ReformatDate Change format of date/time values in the filename. Insert Rule Insert Rule This rule inserts the specified string at the beginning of the name, or end of the name, or at any other specified position. It can also insert the string conditionally (only when the existing name contains a second specified string). The parameters are as follows:
  • 19. Insert Rule 16 Parameter Details What Enter the text that will be inserted. Insert meta tag Click the button to see a list of meta-tags. Where Where to insert the text, select one of the "Where" options described below. Skip extension If this check box is unselected, the extension will be included in the rule. "Where" options Option Details Prefix Adds the string before the existing name. Suffix Adds the string after the existing name. • If the skip extension option is not selected, the specified text will be inserted after the extension. Position Insert at the set position (the count starts from 1). • • Count spaces and special characters also. • You can count in the right-to-left direction • You may use Analyze window to check the position by pointing to the character with mouse or keyboard instead of counting it by yourself. Just select the file (or files) in the Files pane and choose the Analyze name option from the context menu. After text Inserts the text entered in the "what" box after the text entered in the "after text" box. • • If the "after text" string is not found in the name, the "what" text will not be inserted. Before text Inserts the text entered in the "what" box before the text entered in the "before text" box. • • If the "before text" string is not found in the name, the "what" text will not be inserted.
  • 20. Delete Rule 17 Delete Rule Delete Rule This rule will delete all characters located between the From and the Until positions. Optionally, it can delete from the specified position till the end of the name. The parameters are as follows: Parameter Details From From which character-position you want to start the deletion. Select from the following options: • • The starting position (count starts from 1) • • The delimiter from where the deletion starts. • • The delimiter can be a single character or even a string. • Typically , . / ( ) - and space are used as delimiters. Until Till which point you want to delete: Select from the following options: • • Count: Specify how many characters to be deleted, starting from the FROM position. • • Delete till a specified delimiter is reached. • You can use two different delimiters in From and Until sections. • • The delimiter can be a single character or even a string. • Typically , . / ( ) - and space are used as delimiters. • • Delete all characters till the end. Skip extension If this check box is unselected, the extension will be included in the rule.
  • 21. Delete Rule 18 Right-to-left If you select this option, ReNamer counts the position from the extreme right. (The From and Until positions switch places.) • When this option is selected, the "till the end" option in Until deletes all characters on the left (what we regard as the beginning of the name) For example, to keep only the four characters on the right side of the name (and delete all the rest of the characters on the left), use: From Until Position 5 Till the end Do not remove delimiters If you select this option, the delimiters themselves will be retained. • If you have used two different delimiters in From and Until sections, both of them will be retained. Remove Rule Remove Rule This rule removes the specified string from the file name. It has options to remove the first occurrence, the last occurrence, or all the occurrences of the specified string. You can enter multiple strings at a time (just separate them with *|*). If ReNamer finds any of them in the name, they will be removed. You can create a pattern with wildcards, so that any string that matches the pattern will be removed. The parameters are as follows:
  • 22. Remove Rule 19 Parameter Details Remove Enter the string to be removed. • • You can enter multiple strings at a time. Press the + button to separate two strings • • If the name does not contain the specified string, the rule will not act on it. • • If the name contains more than one of these strings, it will remove all of them. TIP: Sometimes, the file names have a common string that needs to be removed. In such cases, rather than entering the whole string by hand, it is easier to borrow it from one of the file names. To do this, just click on a file name in the Files pane of ReNamer BEFORE launching the Remove rule. ReNamer will automatically copy the entire name of the selected file into the Remove field. Now edit this entry to get the desired common string. button Inserts a separator (*|*) sequence between two delimiter entries. (You can directly type *|* instead of clicking on this button.) Occurrences In case the strings occur multiple times in the name, specify which occurrences should be removed. (Options are: first only, last only, or all) Skip extension If this check box is selected, the rule won't touch the extension. Case sensitive Will only remove a specified string from the name if the case matches exactly. Interpret symbols as wildcards Treat certain symbols as Wildcards for matching simple patterns (similar to Regular Expressions). Wildcards Wildcard Represents Example * any number of characters (including numbers, space, underscores, etc.). abc* equals abc followed by 0 or more characters. ? Any single character (including numbers, space, underscores, etc.) ab?d equals abcd, ab1d, ab d, ab_d, etc. [] Brackets enclose a set of characters, any one of which may match a single character at that position. foo[ab]ar equals fooaar and foobar - (only within a pair of brackets) denotes a range of characters. foo[a-z]ar equals fooaar, foobar, foocar, foodar, etc.
  • 23. Replace Rule 20 Replace Rule Replace Rule This rule removes the specified string from the name and replaces it with another string. It has options to replace the first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can create a pattern with wildcards, so that any string that matches the pattern will be removed. The parameters are as follows: Parameter Details Find Enter the string to be replaced. • You can enter multiple strings at a time. They will be searched & replaced in the order as they appear. Press the + button to insert a separator between two strings. Instead of pressing this button, you can also enter *|* from the keyboard. • • If the name does not contain the specified string, the rule will not act on it. • • If the name contains more than one of these strings, it will replace them according to the Occurrences parameter. button Inserts a separator (*|*) sequence between two delimiter entries. (You can directly type*|* You can use this button in the Replace box also. In that case, the nthe entry in the Find box is replaced by the nths entry in the Replace box. (e.g. A -->A', B -->B' etc.) } Replace Enter strings that will replace the "Find" strings. • Note that the number of strings (separated with *|*) in "Find" and "Replace" boxes should be the same. If there is more strings in the "Find" box than in the "Replace" box the spare strings will be removed (replaced with an empty string). If there is more strings in the "Replace" box, the spare strings will be ignored. Insert meta tag Click the button to see a list of meta-tags. Occurrences In case that strings occur more than once in the filename, specify which occurrences should be replaced. (Options are: first only, last only, or all) Skip extension If this check box is selected, the extension will be ignored by the rule.
  • 24. Replace Rule 21 Case sensitive Will only remove a specified string from the name if the case matches exactly. Interpret symbols as wild cards Treat certain symbols as Wildcards for matching simple patterns (similar to Regular Expressions). Wildcards Wildcard Represents Example * any number of characters (including numbers, space, underscores, etc.). abc* equals abc followed by 0 or more characters. ? Any single character (including numbers, space, underscores, etc.) ab?d equals abcd, ab1d, ab d, ab_d, etc. [] Brackets enclose a set of characters, any one of which may match a single character at that position. foo[ab]ar equals fooaar and foobar - (only within a pair of brackets) denotes a range of characters. foo[a-z]ar equals fooaar, foobar, foocar, foodar, etc. Beware of conflicting replacements If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go first and only after replacing all (or first, or last) occurrences of that string the second string in the Find box will be searched & replaced. Find Replace A|B B|A Name New Name ABBA.mp3 AAAA.mp3 You may expect the new name to be BAAB.mp3, but it's not. This happens because first all A's are replaced with B's (we get BBBB.mp3) and only then all B's are replaced with A's (and the final result is AAAA.mp3). If you need to apply character-to-character mappings you should use Translit rule.
  • 25. Rearrange Rule 22 Rearrange Rule Rearrange rule This rule allows you to chop up the existing file name and reuse any/all of the parts in any order to compose a new name. • • You can also add your own text, or use meta tags while composing the new name. • • You can also use the whole original name, and insert literal text (or meta tags) around it. The parameters are as follows: Parameter Description Split using Specifies how to split the existing name into parts. • • You can use only one of the three options at a time (you cannot combine the chopping methods) For detailed explanation of split methods please look below at the split options explained section. Right-to-left If selected, the numbering starts from right. • • The characters of the original names are counted from right (the count begins with 1) • • The chopped parts will also be numbered from right ($1, $2, etc.) Add a separator for additional delimiters. The separator is a "|" (vertical pipe) character, which can also be entered manually. New pattern How to compose the new name from the parts created from the original name (see above). • • You can add meta tags and literal text wherever you want. • • $0 refers to the whole original name. This allows you to quickly compose a new name by inserting a string at the beginning and/or end. Click the button to see a list of meta-tags. Select any meta tag to insert it in the new name template.
  • 26. Rearrange Rule 23 Split options explained Option Description Delimiters Chop the name where the delimiter occurs. • • The delimiter can be a single character or a string. • The chopped parts do not contain the delimiters (they are omitted totally) • • Spaces, numbers and symbols are treated like normal characters. • • Several delimiters can be used at a time. Use the | character to separate them. • • The chopped parts are numbered from left, as $1, $2, $3, etc. The same parts can be referred from the end as $-1, $-2, $-3, etc. • • If the delimiter occurs at the very beginning of the name, the resultant $1 contains nothing (because there is nothing on the left side of the delimiter). Warning: The number of parts into which the filename is broken down depends solely on the number of delimiters in the filename. If you reference fewer parts in the output pattern that the number of available parts - not referenced parts will be lost! For example, take filename "Artist - Title" and to swap them around one would use " - " as a delimiter and "$2 - $1" as a new pattern which will result in "Title - Artist", but if some filename appears with more dashes like "Artist - Title - Album" the result will also be "Title - Artist" and last part will be lost. To make sure that no parts are lost use Exact pattern of delimiters option instead. Positions Chop the name at the indicated position (the position count begins with 1). • If you enter position n, ReNamer will chop the n-th character and all characters beyond that in a separate piece. • • Spaces, numbers and symbols are treated like normal characters. • • No part of the original name is omitted during chopping. • You can enter multiple positions. Separate them with the *|* sequence. • • The chopped parts are numbered from left, as $1, $2, $3, etc. The same parts can be referred from the end as $-1, $-2, $-3, etc. Exact pattern of delimiters Chop the name using the exact pattern (sequence) of the delimiters. With this option you basically define how many parts you want the filename to be split into and the order in which the delimiters must occur. If you specify 1 delimiter then you end up with exactly 2 parts, if you specify 2 delimiters you'll get 3 parts, and so on. Examples This rule is so versatile that it can be used in a huge number of ways. Therefore its examples have been moved to a separate article Rearrange Examples.
  • 27. Extension Rule 24 Extension Rule Extension Rule This rule allows you to attach a new extension. It is useful when the extension of a file is missing (or if the file has a wrong extension). There is an option to find the correct extension based on the file's structure. The parameters are as follows: Parameter Details New extension New extension that has to be added to the filename. Append to the original filename If this option is selected, the new extension will be placed after the old extension. If it is deselected (default option) the new extension will replace the old one. Detect using binary signature Try to detect a correct file extension using built-in Binary signatures of commonly used files. Binary signatures Sometimes the extension of a file is missing. At other times it is simply wrong, e.g. some downloaded files get the aspx extension, although they may actually be zip or pdf files. One way to identify the file extension is by trial-and-error: Attach different extensions and try to open the file with its associated application. This is very tedious. A far more efficient way is to compare the file's digital signature with the signatures of known file types and identify the file's type. This is done internally within ReNamer, so you do not have to know what a digital signature means, or the actual value of the signature for the given file. Note that each extension has a range of signatures, and these ranges overlap. This means a given file's signature may match with the signature of several different extensions. In such cases, ReNamer shows the New filename with all matching extensions. For example, "fileName.wma|wmv|asf". ReNamer also pops up an error window (because the combined extension is invalid). Just read the suggested extensions and then try them out one by one. This method is still better compared to making wild guesses, because ReNamer suggests only 2-3 extensions.
  • 28. Extension Rule 25 For more accurate results, use ReNamer with TrID library, a specialized utility for identifying the file's real extension. Be aware that even TrID often suggests multiple extensions, and you may still have to try them out. Strip Rule Strip Rule Strip characters from the filename. The rule has predefined character sets, like digits, symbols and brackets, but you can also define your own character set. Every occurrence of each of the specified characters will be removed from the filename. The parameters are as follows: Parameter Details English Strip all English characters (both capital and small). • • Numbers (0-9) will not be stripped. • Non-English characters will not be stripped. (e.g. characters with diacritical mark [1] , which are used in many languages in Europe and Asia) Digits Strip digits Symbols Strip symbols (all characters that are considered to be symbols are showed in the box on the right) Brackets Strip brackets (but not the contents of the brackets) • If you want to delete the content as well, use the CleanUp rule instead. User-defined Define any character that needs to be stripped off. • • Note that this is not a string. All characters in the entry are searched for individually and removed. Strip all characters except selected Retains the selected characters only, and strips the rest. • This option is very useful to strip all non-English characters: Select this option along with the English option above. Skip extension If this check box is selected, the extension will be ignored by the rule.
  • 29. Strip Rule 26 References [1] http://en.wikipedia.org/wiki/Diacritic Case Rule Case Rule This rule changes the case of the filename. Options are: capitalize, to lower case, to upper case, invert case, and put only first letter capital (as in a sentence). There is also an option to force case for specific text-fragments, such as CD, DVD, RF, etc. These fragments would not look natural in any other case (e.g. cd, dvd, rf), so the rule allows you to prevent changing the case of such terms in one stroke. The parameters are as follows: Parameter Details Case change Several options are offered. • The case of each option itself illustrates how that option works. For example, Capitalize Every Word. • Capitalize Every Word will first make all letters lowercase and then convert the first letter of each word into UPPERCASE. • Capitalize AND Preserve will convert the first letter of each word into UPPERCASE; but will not affect the rest of the letters. • all lower case will convert all letters to lowercase. • ALL UPPERCASE will convert all letters to UPPERCASE. • iNVERT cASE will change all capital letters to lowercase, and all lowercased letters to UPPERCASE. • First letter capital will change only the first letter to UPPERCASE, and rest of the letters to lowercase. (Compare this with the Capitalize AND Preserve option above.)
  • 30. Case Rule 27 • The (none of the above) option is provided to disable the case conversions listed above it, so you could independently use the options listed on the right side of the window. This allows you to convert the case of extension, or case-convert specific text fragments (see below). Skip extension If this check box is selected, the extension will be ignored by the rule. Force case for fragments This option forces the case of specified text-fragments (strings) in the file name. Note: This check box is coupled with the box below it. (Enter the fragments in the box and then activate the option by selecting the check box.) • • You can set any case for the strings (ALLCAPS, Only first letter capitalized, lowercase, MixedCase, etc.) • You can specify multiple strings at a time, each with its own case format. To separate the strings from each other, put a comma between them. (Note: In versions prior to v5.50, a space was used instead of a comma.) • The case for these strings will be set exactly as entered in the box, regardless of the options selected in Case change list. Extension always upper case Forces the extension to uppercase. Note: This setting overrides any other setting that can alter the extension. For example, consider a case where the all lowercase option is selected and the skip extension option is deselected. Logically, the extension should be converted into lowercase too. But if the Extension always upper case option is selected, the case of the extension will be converted to uppercase. This setting will override even the fragments case-conversion. Extension always lower case Forces the extension to lowercase. Note: This setting overrides any other setting that can alter the extension. For example, consider a case where the ALL UPPER CASE option is selected and the skip extension option is deselected. Logically, the extension should be converted into ALLCAPS. But if the Extension always lower case option is selected, the case of the extension will be converted to lowercase. This setting will override even the fragments case-conversion. Examples of Force case option You may want to use a very specific case format for certain text fragments, irregardless of other case options. Here are some typical examples where "Force case" option may be useful: Desired case format Examples ALLCAPS CD, DVD, TV, HTML, XML, C++, USA, GIMP Only the First letter capitalized Java, India, English, Sunday, Easter, February Mixed case OpenSUSE, OpenOffice, ReNamer
  • 31. Serialize Rule 28 Serialize Rule Serialize Rule This rule works on a set of files, and inserts incremental numeric series of digits in the names of those filenames. The files listed in the pane can be numbered in increasing or decreasing order, with various steps, repeat and reset configuration. The position of each file in the Files pane becomes important, so check the order of the files in the list before applying this rule. Examples: 1. 1. You have a bunch of log files, and you want to make them look like "log0001", "log0002", "log0003", etc. 2. 2. You want to force specific sorting for files: "01 - Song XYZ", "02 - Song ABC", "03 - Song YYY", etc. The parameters are as follows: Parameter Description Index start Starting number. For example, if the destination folder already has some files with serialized numbers, you can start with the next number. Step Increment the index by this value after each processed file. Usually 1, but you may like to enter a higher number here if files with intermediate numbers are expected later. Also, negative numbers can be used to make decremental indexes, e.g. -1, -2, -3, etc. Repeat How many times to repeat (reuse) the same index before incrementing it. Reset every Reset index to the initial value after processing this many files. Reset if folder changes Since ReNamer can work on files collected from multiple folders, this control allows you to reset the counter for each of those folders. The effect is as if you are repeating the same command for each of the folders separately.
  • 32. Serialize Rule 29 Reset if file name changes Reset the counter when the file name changes. This option is especially useful for fixing (serializing) duplicated file names, when the files with the same name are grouped together, which can be achieved by sorting the files by name or path. Pad with zeros to length Pad the inserted number with leading zeros. For example, "457" becomes "000457" if it is padded to reach 6 digits, and "0457" if padded to 4 digits. Insert where Specify where to insert the number (see below for individual options). Insert location Options for where to insert the number: Option Description Prefix Before the original filename Suffix After the original filename Position Insert the number at the specified position. Replace current name Inserted number replaces the entire filename. Skip extension Exclude file extension when calculating the position for insertion. Numbering system A choice of the Numbering system dictates which symbols and enumeration technique are used for the serialization. Number system Description / Examples Decimal digits Index starts at 0 with repeat 1 and step 1: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, … English letters Index starts at 1 with repeat 1 and step 1: a, b, c, …, x, y, z, ba, bb, bc, …, bx, by, bz, ca, cb, cc, …, zx, zy, zz, baa, bab, bac, … Index starts at 1 with repeat 1 and step 1, pad to length 3: aaa, aab, aac, …, aax, aay, aaz, aba, abb, abc, …, abx, aby, abz, aca, acb, acc, …, azx, azy, azz, baa, bab, bac, … Roman numerals Index starts at 1 with repeat 1 and step 1: I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, … Simplified Chinese Index starts at 1 with repeat 1 and step 1: 一, 二, 三, 四, 五, 六, 七, 八, 九, 一十, 一十一, 一十二, 一十三, … Custom alphabetic Index starts at 1 with repeat 1 and step 1, using "ABC" symbols: A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, … Index starts at 1 with repeat 1 and step 1, using "01" symbols: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, … Custom numeric Index starts at 0 with repeat 1 and step 1, using "ABC" symbols: A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, … Index starts at 0 with repeat 1 and step 1, using "01" symbols: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, …
  • 33. Randomize Rule 30 Randomize Rule Randomize Rule This rule inserts randomly generated sequences of specified length and using a selection characters (digits, letters, or a custom set). Several common practical uses: 1. 1. Randomize the order files. 2. 2. Destroy existing filenames. The parameters are as follows: Parameter Description Length of random sequence Specify how many characters your random sequence should have. For example, if you are using only digits and set length to 4, you will will get random numbers from 0000 to 9999 (inclusive). Unique if possible Normally, randomly generated values can repeat themselves. If this option is selected, ReNamer will generate unique values (no repetition) when possible. Characters to use The set of characters which will be used for generating random sequences. You can choose between using digits (0..9), English letters (a..z) or specify your custom set of characters. Insert where Specify where to insert the number (see below for individual options). Options for where to insert the number:
  • 34. Randomize Rule 31 Option Description Prefix Before the original filename Suffix After the original filename Position Insert the number at the specified position. Replace current name Inserted number replaces the entire filename. Skip extension Exclude file extension when calculating the position for insertion. Clean Up Rule CleanUp Rule This rule cleans up the filenames from (or for) commonly used naming conventions for Internet, peer-to-peer networks and other resources. Multiple problems can be removed at once. The parameters are as follows:
  • 35. Clean Up Rule 32 Parameter Details Strip out content of brackets A typical use of this option is to strip the needless comments attached to filenames, such as (best!!). • • This option removes the brackets also. • • You can select any/all of the various types of brackets. If you do NOT want to delete the content within the brackets, use the Strip rule instead. Replace these characters with spaces These characters occurring in the file names are removed and a space is inserted in their place. Fix spaces Replace multiple consecutive spaces with a single space. It also removes spaces from the beginning and the end of the filename: • If skip extension is selected it removes spaces from the beginning and end of the base name (before the extension). • If skip extension is deselected it removes spaces from the beginning and from the end of the filename (after the extension). Normalize unicode spaces Replace all Unicode white space characters with a standard space bar character code. Unicode character set contains a number of different characters (C1_SPACE type) that represent a white space with slightly different properties (e.g. wider, narrower, etc). Insert a space in front of capitalized letters Often words in the file name are just joined together, without spaces or underscores to separate them. Each word begins with a capital letter, so that you can read it easily. This option separates such words in the file name. For example, SeparateTheseWords.pdf becomes Separate These Words.pdf. (Note that if there is a capitalized letter at the very beginning of the name, ReNamer does NOT add a space before it.) Prepare for SharePoint Prepares the file for hosting it on Microsoft Sharepoint [1] . 1. 1. strips standard forbidden filename characters 2. 2. strips consecutive dots 3. strips #, %, ~, & 4. replaces { and } with ( and ) Skip extension If this check box is selected, the extension will be ignored by the rule. References [1] http://www.microsoft.com/sharepoint/prodinfo/what.mspx
  • 36. Translit Rule 33 Translit Rule This rule transliterates one alphabet into another. Its main goal is to transliterate Non-English characters from different languages into their English/Latin representation. For example, the German character ü can be transliterated to ue (the name Müller can be also written as Mueller). This rule uses transliteration maps (explained below). Transliteration maps To transliterate, we create a pair of equivalent characters, like this: ü=ue (Note that the right side of this equation has two characters. Any number of characters may be placed on both sides of the equation.) We need several such equivalent character pairs to convert one language into another. The entire set is called a transliteration map. (This is really some kind of a find-and-replace rule.) ReNamer has several such built-in maps. Each map is named after a language (the second language in all maps is English). Each map can be used in both directions (e.g. French-to-English or English-to-French.) When you start up the Translit Rule, its window does not show any maps. You are free to do any of the following: 1. Use any of the built-in maps (and use it in forward or reverse direction) 2. 2. Create your own map and use it. 3. 3. Edit a built-in map first, and then use it. Let us see how to do this.
  • 37. Translit Rule 34 Automatic case conversion Translit rule does automatic case conversion with an algorithm adopted specifically for transliteration. Translit rule discard the case on the input, i.e. "A=B" is same as "a=b". Case is decided upon case of the input fragment. Multiple character fragments are treated as part of words, with their case decided based on the case of letters around them. The logic for the case conversion is as follows (ReNamer Beta from 23 Aug 2009): set OUTPUT-PART to lower case if first letter in INPUT-PART is upper case then if length of OUTPUT-PART bigger than 1 then if next letter in original name is upper case then convert whole OUTPUT-PART to upper case else convert only first letter in OUTPUT-PART to upper case else convert whole OUTPUT-PART to upper case Using a built-in transliteration map To select any of the built-in maps, press the button. A list of available transliteration maps pops up: Click on the desired transliteration map. As an example, let us click on the French (to English) transliteration map. The Rules window changes immediately to show the French characters and their English equivalents.
  • 38. Translit Rule 35 You can edit any of the entry in this list, add new entries, or delete any of the entries. Note that such editing does not alter the saved version of the map. (The map is edited just for a one-time use. So, if you select the same Translit map again, ReNamer will load the original version, not the edited version.) We will see how to edit and save a map later. Next, select the rule's parameters as shown below: Parameter Details forward This is transliteration from-left-to-right direction, as defined in the map. backward This is transliteration from-right-to-left direction, as defined in the map. skip extension If this check box is selected, the extension will be ignored by the rule. Finally, press the button to add the rule to the stack. Making your own transliteration map Click in the Translit Alphabet window, and start entering your custom alphabet. Transliteration alphabet consists of two equivalence parts (or a couple), which are entered one per line and two parts separated with "=" (equal sign). Alphabet should not contain spaces and should have case discarded (case is adjusted automatically). Also, make sure to put couples which contain greater number of characters at the top, so they will get processed first and will not get processed partially by shorter representations. Below is a simple example: щ=sh ю=yu я=ya ь=' э=e After entering all such transliterations, press the button to add the rule to the rule-stack. Note that this rule is not saved yet (it was just composed for a one-time use). The following topic shows how to save a map.
  • 39. Translit Rule 36 Saving a transliteration map To save a newly composed Transliteration rule, 1. Press the button. A menu pops up. 2. Select the last option (Save Translit...). A window pops up, as shown below: 3. Enter a new name for the map and press OK. The new map is saved. The process of saving an edited Transliteration map is similar. The only difference is that the Save Translit window (see above) shows the current map's name. You can press OK to save the changes you've just made, or enter a new name to create a new translit map for the edited version of the current map. The new map's name is added to the map list. From now on, the new map will also be available as "standard".
  • 40. Regular Expressions Rule 37 Regular Expressions Rule This rule finds text that matches the specified RegEx pattern, and replaces it with another string. RegEx is short for Regular Expressions, which stands for special syntax for describing search and replace patterns. Regular Expressions are very powerful and they are really worth learning. The RegEx syntax is explained in the appendix. Note: The TRegExpr [1] RegEx engine used by ReNamer is a little different from the standard PERL RegEx [2] or Windows RegEx [3] . You may check the correct syntax in Regular Expressions section. The parameters are as follows: Parameter Details Expression RegEx pattern to match or find. Replace RegEx pattern that replaces the found pattern. Skip extension If this check box is selected, the extension will be ignored by the rule. Case-sensitive If this option is selected, ReNamer will search for the text in case-sensitive manner. A simple set of commonly used RegEx syntax patterns is provided in the hint menu:
  • 41. Regular Expressions Rule 38 Tip: ReNamer users have posted many RegEx patterns at the User Forum [1] . You can copy and use them. References [1] http://www.regexpstudio.com/ [2] http://perldoc.perl.org/perlre.html [3] http://msdn.microsoft.com/en-us/library/6wzad2b2(VS.85).aspx
  • 42. Pascal Script Rule 39 Pascal Script Rule This rule uses Pascal Script programming engine with syntax and conventions similar to Delphi/Pascal. ReNamer comes with some preloaded scripts. We will see how to use them, and how to add a new script. Using a ready script 1. Click on the button (located just below the Configuration pane). A list of scripts appears. 2. All available scripts are listed above the line. Click on any script to load it into the Configuration pane. 3. 3. Edit the script if required 4. Press button to add the script to the rule stack. Alternatively, you can drag and drop an existing file from your desktop of favourite explorer straight into the script window. Hold SHIFT key when opening a new script to insert it into the current script at the cursor position, instead of completely replacing the current script. This can be useful when you store your commonly used functions in separate
  • 43. Pascal Script Rule 40 script files, and with this feature they can be easily merged into the current script. Borrowing scripts from forum Even if you do not know how to write a script, you can easily use scripts written by others. First, visit the User Forum [1] and search for a suitable script. The Forum already has a large number of such scripts. Some of these scripts have embedded comments about how to customize the script. If you cannot find a suitable script, you can ask other users to write the script for you. TIP: If you are looking for scripts only, try to use begin or end words in your search phrase as these are the words that are present in every single script. Once you find such a script, follow these simple steps: Step Details 1 Copy the script Copy the script from the forum (ensure that nothing is left out). 2 Clear the ReNamer's Configuration pane Open the Pascal Script Rule in ReNamer. Select the three lines you see in the Configuration pane, and press DEL or paste the script while these lines are selected. • • The three lines already provided in the window are meant to begin a script from scratch; but since you are pasting a ready-made script, they must be removed first, otherwise they will interfere with your script. 3 Paste the script into ReNamer pane Use the CTRL+V shortcut or right-click and select Paste. 4 Compile the script Press the button. • • In case some error comes up, the error message will identify the line number of the faulty statement. You can try and troubleshoot the problematic statement in the script using the button. ReNamer opens a window like this: Now enter the line number in the window and press OK. It takes you to the faulty statement. Try to edit the statement and compile the script again. (Note that if the script compiles successfully, the button is not required at all.)
  • 44. Pascal Script Rule 41 5 Saving the script and giving it a name: The save button is hidden under the scripts menu. So first click on the button. It pops up a window like this: Note that all the existing scripts are listed here. (When you save the new script, it will also be added to this list.) Select the Save script... option (at the very bottom of the menu). Another window pops up. Enter a name that suggests the function of your script. Press OK. The new name is added to the list of scripts. Now use it as described above. Writing your own scripts To write your own scripts, you must have knowledge of Pascal script. Learning Pascal script is easy. Refer to the Pascal Script section. Here, we will assume that you already know how to write pascal scripts. The step-by-step procedure is as follows: 1. Click in the Configuration pane and enter the script directly. (You can also copy it from anywhere and paste it into the pane by pressing CTRL+V. Or right-click in the pane and select the Paste option from the context menu.) 2. Compile the script by pressing the button located below the Configuration pane. • If an error message comes up, troubleshoot the script. The fault message usually includes the line number of the problematic statement in the script. Press the button and enter that line number to locate the faulty statement quickly. Then correct the errors and press the button again. Repeat this till a Compiled successfully! message pops up. 3. Now you can add the script as a rule by pressing button or save it for later use. 4. To save the script press the button. A list pops up:
  • 45. Pascal Script Rule 42 5. Click on the Save Script...(the last option in the list). Now this script is added to the list (it appears above the line in the list). • • Now you can use that script as described above. User Input Rule This rule replaces the original filenames with the names taken from the list. (The nth line in the list serves as the new name for the nth file in the Files pane.) Naturally, the list should contain names for all the files loaded in the Files pane. • • If the list is shorter, then some of the files will not be renamed. • If the list is longer, some of the names will remain unused (but all files in the Files pane will be renamed). There are three ways to create the list: 1. 1. Click in the pane, and manually type the list (one name per line). 2. Copy the list from any application to your clipboard. Switch to ReNamer. Click in the UserInput pane and press CTRL+V, right-click and select Paste or choose the Load from clipboard from menu). 3. Load a list from the text file (available from menu).
  • 46. User Input Rule 43 The optional parameters are as follows: Parameter Description Insert in front of the current name Inserts the name before the file name. Insert after the current name Inserts the name after the current name. The actual position depends on the Skip extension option. Replace the current name Replaces the existing filename with the new name. The effect on extension depends on the Skip extension option: Skip extension • • If the option is selected, the extension is ignored and user input strings will affect only the base name of files. • If the option is deselected, user input strings will replace entire filename, including the extension, or will be added after the old extension (if the Insert after the current name option is selected). Examples For example, if you have this three files: • • Old name 1 • • Old name 2 • • Old name 3 Then your list of new names should contain exactly three lines like: • • New name for old name 1 • • new name for old name 2 • • New name for old name 3 Example 1 File list is longer then the list of new names: File name List of new names One.txt First.txt Two.txt Second.txt Three.txt Third.txt Four.txt (will not be renamed) Example 2 List of new names is longer then the file list:
  • 47. User Input Rule 44 File name List of new names One.txt First.txt Two.txt Second.txt Three.txt Third.txt (not used) Fourth.txt Example 3 Missed item in the list of new names can cause incorrect ordering: File name List of new names One.txt First.txt Two.txt Third.txt Three.txt Fourth.txt Four.txt Fifth.txt Reformat Date Rule This rule allows finding and reformatting various date/time values in the filename. Allowed date/time format variables are described in the Date and Time format article.
  • 48. Reformat Date Rule 45 Parameter Description Find date/time format Find date and/or time matching a specified format. A dropdown menu provides a quick access to commonly used formats. Convert to date/time format Convert found date and/or time values to the specified format. A dropdown menu provides a quick access to commonly used formats. Match as whole words only When searching for a matching date/time pattern, match only if the found pattern is a whole word, i.e. surrounded by word boundaries. For example: A 4 digit year pattern (YYYY) will be found in "foo1234bar" if this option is disabled, but not found if option is enabled. Skip extension Exclude file extension from processing. Use custom short months Use a custom list of short month names when searching or formatting short month name pattern (MMM). Month names are separated by a comma. By default, month names from the system locale are used. Use custom long months Use a custom list of long month names when searching or formatting long month name pattern (MMMM). Month names are separated by a comma. By default, month names from the system locale are used.
  • 49. 46 Pascal Script Pascal Script The PascalScript Rule in ReNamer uses Pascal Script component to allow users to program their own renaming rule. To master Pascal Script, follow these steps: 1. 1. Learn the basic syntax and concepts of Pascal Script 2. 2. Understand the specific variables, procedures and functions that are defined within ReNamer 3. 3. Learn how to use these variables/functions/procedures in scripts Let us see these steps in more details. Learn the basics To learn the basics of Pascal Script, please refer to the Pascal Script Quick Guide. Types and functions In this section, we will see all types, procedures and functions which can be used within ReNamer. • • Types • • Procedures and functions Note: Most of these are not part of the "standard" Pascal Script, so you may not find them in other applications. Script cookbook In this section, we will see how to write scripts for some common renaming tasks. They also demonstrate how to use ReNamer's types, procedures and functions. 1. 1. How to rename a file (using the FileName variable) 2. 2. How to skip extention (basic FileName utilities) 3. 3. How to convert the filename to ALLCAPS (the WideUpperCase function) 4. 4. How to operate on words (Unicode string-handling routines) 5. 5. How to serialize files (basic conversion routines) 6. 6. How to initialize variables 7. 7. How to create interactive dialogs 8. 8. How to work with folders and paths (FilePath constant) 9. 9. How to break the script execution 10. 10. How to read file content 11. 11. How to import functions 12. 12. How to split file path into parts (folders, base, extension) 13. 13. How to store/load variables for later reuse
  • 50. Pascal Script 47 Scripts repository • Official Scripts Repository. • The Forum [1] contains several ready scripts. Study them and adopt them for your purpose. Tips A few quick tips: • In Pascal Script, ReNamer has defined the FileName variable to represent the "New Name" of a file. Therefore, in your script, you will have to manipulate this variable to change the filename. Changes to the FileName variable do not actually change the name of the file, they simply change the value in the "New Name" column. Changes are applied only when you click the "Rename" button. • The FilePath constant holds the original path of the file. It allows you to access the file directly. • ReNamer supports User Defined Functions (UDF) and also importing of external functions from DLLs. • Try to use WideString type instead of an ordinary String type. This will allow ReNamer to handle Unicode filenames. In other words, it will be able to handle non-English scripts, such as Cyrillic, Asian, German, French, etc. • You may use {$INCLUDE 'filename.inc'} directive to include code from an external file, allowing for easier reuse and better organization of your code. Available since v6.5.0.1 Beta. Warnings: • • Do not override ReNamer's built-in variables, types and functions. • • Some functions are able to alter your file system, e.g. create new folders, change file content, delete files, etc. Use such functions with caution! Remember that scripts are executed during Preview (not Rename) operation and they can be get executed automatically if Auto Preview is enabled. External links • RemObjects Pascal Script [1] Developers of the Pascal Script component. • Delphi Basics [2] Help and reference for the fundamentals of the Delphi/Pascal language. References [1] http://www.remobjects.com/ps [2] http://www.delphibasics.co.uk/
  • 51. Quick Guide 48 Quick Guide If you are not familiar with Pascal Scripting, first go through the excellent tutorial [1] written by Tao Yue. The following is a short overview of Pascal Script. Basic pascal script The structure of a basic script is as follows (keywords are shown in ALLCAPS bold): CONST <Constant declarations> TYPE <Type declarations> VAR <Variable declarations> BEGIN <Executable statements> END. Note that: • The main code must be within the begin and end. keywords. • All statements in the script use the semicolon ";" as terminator. Only the last statement (END.) uses a dot as terminator. Control structures All the typical control structures (building blocks) occurring in Pascal Script are described in the following table. The table shows a flow chart and Pascal Script code required to implement that logic. To compose your own PascalScript rule, you can simply copy and paste the code and then edit it to finish your script. In actual implementation, just substitute the following: • Replace <Condition> with an actual Pascal statement that tests for a condition. • Replace <Action> with code block that takes action relevant to the condition. There may be several statements. Branching These structures are used to execute different blocks of code depending upon a condition.
  • 52. Quick Guide 49 Branching structure Pascal script Flowchart (Logic) Remarks if-then if <Condition> then begin <Action> end; Execute the <Action> statement only if the <Condition> is met. Otherwise pass on the control to the next statement that follows the <Action>. if-then-else if <Condition> then begin <Action-1> end else begin <Action-2> end; Two alternative actions are provided. If <Condition> is met, execute <Action-1>. Otherwise execute <Action-2>. Thus one of these two <Actions> are definitely executed. After execution of the action, pass on the control to the next statement. case/switch case X of 1: begin <Action-1> end; 2: begin <Action-2> end; else begin <Default Action> end; end; This code structure has several <Action> blocks, each with its own condition. • Any given <Action> block is executed only if its condition is met. • One and only one <Action> is executed. After that, the control passes on to the next statement. (It does not check for the next condition.) • The conditions are checked in the "top down" order. So even if the other conditions are also met, their <Actions> will never be executed. • The code structure can optionally have a <Default Action>. It is executed if (and only if-) none of the conditions are met. This is a generalized version of the if-then-else block (above).
  • 53. Quick Guide 50 Loops Loops are used to execute a block of code iteratively till a certain condition is met. Loops Pascal script Flowchart (Logic) Remarks For To Do for I := X to Y do begin <Action> end; Execute the <Action> a certain number of times. This example shows that the counter is incremented by 1, but it can be any statement that changes the value of the counter vaiable towards the target value. Similarly, the decision block can have any logical expression with the counter. Make sure that the exit condition is reached at some point of time; otherwise the loop will execute endlessly, and ReNamer will appear to be hung. While Do while <Condition> do begin <Action> end; Check for a condition and if it is met, execute the <Action>. The loop is repeated till the condition is met. When the condition is not met, the loop is terminated and control passes to the next statement. Note that if the condition fails in the first-ever check, the <Action> may not be executed at all. Make sure that the condition will fail at some point of time; otherwise the loop will execute endlessly, and ReNamer will appear to be hung. Sometimes the condition is set to be always TRUE, and then a statement inside the <Action> block breaks the loop based on a different condition.(See the break command below) Repeat Until repeat <Action> until <Condition>; This structure is similar to the While loop (see above). However, the only difference is that the <Action> is taken first and then the condition is checked. As a result, the <Action> is executed at least once.
  • 54. Quick Guide 51 Break Break; OR if <Condition> then Break; This statement is placed in any of the above loops to terminate the loop when a condition is met. Typically, it is used as the <Action> statement in a if-then block. This block is then embedded (nested) inside the other code block that is to be contionally terminated. See the Case block above, which uses the break statement as integral part of its structure. Continue Continue; OR if <Condition> then Continue; This statement is placed in any of the above loops to jump to the end of the current iteration, bypassing all the subsequent statements within the loop. However, the execution of the loop continues (the next iteration starts). Typically, it is used as the <Action> statement in a if-then block. This block is then embedded (nested) inside the other code block, just before the statements that are to be skipped in the current iteration. Control Exit Exit; OR if <Condition> then Exit; The Exit procedure abruptly terminates the current function or procedure. If exiting a function, then Result contains the last set value. Warning: use with caution - jumping is a concept at odds with structured coding - it makes code maintenance difficult. References [1] http://www.taoyue.com/tutorials/pascal/contents.html Types This page lists and explains all supported types in Pascal Script used within ReNamer. Integer types Type Size Lowest Value Highest Value Byte 1 byte 0 255 ShortInt 1 byte -128 127 Word 2 bytes 0 65,535 SmallInt 2 bytes -32,768 32,767 Cardinal 4 bytes 0 4,294,967,295 Integer 4 bytes -2,147,483,648 2,147,483,647 Int64 8 bytes -9,223,372,036,854,775,808 9,223,372,036,854,775,807 Floating point types
  • 55. Types 52 Type Size Range Single 4 bytes 1.5 x 10 -45 .. 3.4 x 10 38 Double 8 bytes 5.0 x 10 -324 .. 1.7 x 10 308 Extended 10 bytes 3.6 x 10 -4951 .. 1.1 x 10 4932 String types Type Description Char Stores a single Ansi character. String Holds a sequence of Ansi characters of any length. AnsiChar Alias for Char type. AnsiString Alias for String type. WideChar Stores a single Unicode character. WideString Holds a sequence of Unicode characters of any length. Note: Unicode article highlights the difference between Unicode and Ansi. Mixed types Type Description Boolean Provides an enumeration of the logical True and False values. Array Single and multi dimensional indexable sequences of data. Record Provides means of collecting together a set of different data types into one named structure. Variant Provides a flexible general purpose data type. PChar Pointer to a Char value, and can also be used to point to characters within a string. Extra types Several extra types have been defined to simplify the use of some functions. Type Declared as Description TDateTime Double Holds date and time TStringsArray Array of WideString Holds an indexable sequence of WideString. Deprecated in v5.74.4 Beta. Please use TWideStringArray instead. TWideStringArray Array of WideString Holds an indexable sequence of WideString. Added in v5.74.4 Beta. Replaces ambiguous TStringsArray type. TAnsiStringArray Array of AnsiString Holds an indexable sequence of AnsiString. Added in v5.74.4 Beta.
  • 56. Types 53 Enumerations and Sets For example, the Boolean data type is itself an enumeration, with two possible values: True and False. If you try to assign a different value to a Boolean variable, the code will not compile. Example Description type TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun); var Day: TDay; begin Day := Mon; if Day <> Tue then Day := Wed; end. An enumeration is simply a fixed range of named values type TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun); TDays = set of TDay; var Days: TDays; begin Days := [Mon, Tue, Wed]; if Sun in Days then Days := Days - [Sun]; end. Whereas enumerations allow a variable to have one, and only one, value from a fixed number of values, sets allow you to have any combination of the given values Functions ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the PascalScript rule. The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything. A common prefix Wide in the function name indicates that the function deals with Unicode strings (WideString). ReNamer has similar functions without Wide prefix, for processing ANSI strings. For example, ShowMessage and WideShowMessage procedures. Basic String Handling
  • 57. Functions 54 Routine Remarks procedure Insert(Source: String; var S: String; Index: Integer); Inserts the string S into string Source at position Index. procedure Delete(var S: String; Index, Count: Integer); Deletes Count characters from the string S, starting from position Index. function Copy(S: String; Index, Count: Integer): String; Copies Count characters from string S, starting at position Index, and returns them as a new string. function Pos(Substr: String; S: String): Integer; Returns the position of a string Substr in another string S. Note: Indexes of characters in strings are 1 based, so first character in string S would be S[1]. Length Management Routine Remarks procedure SetLength(var S: Array; NewLength: Integer); Sets the length of array variable S to NewLength. procedure SetLength(var S: String; NewLength: Integer); Sets the length of string variable S to NewLength. procedure SetLength(var S: WideString; NewLength: Integer); Sets the length of widestring S to NewLength. function Length(const S: Array): Integer; Returns the length of array S (number of elements). function Length(const S: String): Integer; Returns the length of string S (number of characters). function Length(const S: WideString): Integer; Returns the length of WideString S (number of characters). Unicode String Handling Routine Remarks procedure WideInsert(const Substr: WideString; var Dest: WideString; Index: Integer); Inserts Substr in Dest at position Index. procedure WideDelete(var S: WideString; Index, Count: Integer); Deletes Count characters from S, starting from the Index position. procedure WideDeleteRight(var S: WideString; Index, Count: Integer); Delete Count characters from S, starting from the Index position from the end and counting towards the start. Added in v6.0.0.9 Alpha. procedure WideSetLength(var S: WideString; NewLength: Integer); Change the length of string S to a new length specified by NewLength. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything. function WideLength(const S: WideString): Integer; Returns the length of WideString S. function WideCopy(const S: WideString; Index, Count: Integer): WideString; Returns Count characters from S, starting at position Index. (Index is zero based) Example: myVarFirst4Signs:=WideCopy(FileName,0,4); function WideCopyRight(const S: WideString; Index, Count: Integer): WideString; Returns Count characters from S, starting at position Index from the end and counting towards the start. Added in v6.0.0.9 Alpha. function WidePos(const SubStr, S: WideString): Integer; Find and occurrence of SubStr in S. Returns the position of first occurrence, or 0 if nothing was found. function WidePosEx(const SubStr, S: WideString; Offset: Cardinal): Integer; Find and occurrence of SubStr in S but start searching from position specified by Offset. Returns the position of first occurrence, or 0 if nothing was found.
  • 58. Functions 55 function WideUpperCase(const S: WideString): WideString; Returns the ALLCAPS version of the WideString S function WideLowerCase(const S: WideString): WideString; Returns the lowercase version of the WideString S function WideCompareStr(const S1, S2: WideString): Integer; Compares two WideStrings S1 and S2, case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2. function WideCompareText(const S1, S2: WideString): Integer; Compares two WideStrings S1 and S2, case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2. function WideSameText(const S1, S2: WideString): Boolean; Compares two WideStrings S1 and S2, case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE. function WideTextPos(const SubStr, S: WideString): Integer; Behaves like WidePos function, except text if processed in case-insensitive manner. function WideTextPosEx(const SubStr, S: WideString; Offset: Cardinal): Integer; Behaves like WidePosEx function, except text if processed in case-insensitive manner. Added in v6.6.0.1 Beta. function WideTrim(const S: WideString): WideString; Removes leading and trailing spaces and control characters from the given string S. function WideTrimChars(const S, CharsToTrim: WideString): WideString; Remove characters that occur in CharsToTrim from the beginning and the end of S. Added in v6.0.0.9 Alpha. function WideTrimCharsLeft(const S, CharsToTrim: WideString): WideString; Remove characters that occur in CharsToTrim from the beginning of S. Added in v6.0.0.9 Alpha. function WideTrimCharsRight(const S, CharsToTrim: WideString): WideString; Remove characters that occur in CharsToTrim from the end of S. Added in v6.0.0.9 Alpha. function WideReverseString(const S: WideString): WideString; Return a reversed version of string S, i.e. reverse the order of characters. Added in v6.7.0.4 Beta. function WideRepeatString(const S: WideString; Count: Integer): WideString; Repeat a string a number of times. Added in v6.9.0.3 Beta. function WideReplaceStr(const S, OldPattern, NewPattern: WideString): WideString; Return a result of a case-sensitive replacement of all occurrences of OldPattern with NewPattern in a string S. function WideReplaceText(const S, OldPattern, NewPattern: WideString): WideString; Return a result of a case-insensitive replacement of all occurrences of OldPattern with NewPattern in a string S. function WideSplitString(const Input, Delimiter: WideString): TWideStringArray; Splits the Input wherever Delimiter occurs and returns an array that contains the split parts. • The Delimiter itself can be a multi-character WideString. (Unlike the usual comma, hyphen or space that are used for this purpose) • The split parts (returned as elements of the array) do not contain the Delimiter. function WideJoinStrings(const Strings: TWideStringArray; const Delimiter: WideString): WideString; Joins all individual items from Strings into a single WideString, with Delimiter inserted between the joined items. function WideCaseSentence(const S: WideString): WideString; Returns a Sentence case version of parameter S. Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase. Added in v6.0.0.3 Alpha. function WideCaseCapitalize(const S: WideString): WideString; Returns the Title case version of parameter S. First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.
  • 59. Functions 56 function WideCaseInvert(const S: WideString): WideString; Inverts case of all characters in S and returns it. Unicode Character Handling Function Remarks function IsWideCharUpper(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is in UPPERCASE. function IsWideCharLower(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is in lowercase. function IsWideCharDigit(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a digit (numeric character 0-9). function IsWideCharSpace(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE). function IsWideCharPunct(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT). function IsWideCharCntrl(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a control character (characters classified as C1_CNTRL). function IsWideCharBlank(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK). function IsWideCharXDigit(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a hexadecimal digit (0-9 or A-F). function IsWideCharAlpha(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a alphanumeric character (a-z or A-Z). function IsWideCharAlphaNumeric(WC: WideChar): Boolean; Checks a Unicode character WC and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9). function IsWideWordBoundaryLeft(const Subject: WideString; CharPosition: Integer): Boolean; Check if a character at the specified position is on a word boundary to the left. Conditions that qualify as word boundaries to the left of character: 1. 1. If first character and is a word character. 2. 2. Between word and not a word character. Added in v6.6.0.1 Beta. function IsWideWordBoundaryRight(const Subject: WideString; CharPosition: Integer): Boolean; Check if a character at the specified position is on a word boundary to the right. Conditions that qualify as word boundaries to the right of character: 1. 1. If last character and is a word character. 2. 2. Between word and not a word character. Added in v6.6.0.1 Beta. function WideCharUpper(const WC: WideChar): WideChar; Returns a UPPERCASE version of the input Unicode character. In case of non-alphabetic character, it returns the same character. function WideCharLower(const WC: WideChar): WideChar; Returns a lowercase version of the input Unicode character. In case of non-alphabetic character, it returns the same character. function WideChr(Code: Word): WideChar; Create a Unicode character from a code point. Added in v6.9.0.3 Beta. Note: Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: http://www.fileformat.info/info/unicode/ [1] .
  • 60. Functions 57 Unicode Conversion Function Remarks function WideToAnsi(const WS: WideString): String; Converts a Unicode string to its ANSI version. function AnsiToWide(const S: String): WideString; Converts a ANSI string to its Unicode version. function UTF8Encode(const WS: WideString): String; Convert Unicode string to the UTF-8 [2] encoded string. Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file. function UTF8Decode(const S: String): WideString; Convert UTF-8 [2] encoded string to its full Unicode representation. Console Output Conversion OEM-defined character set is commonly used in the output of console applications. Function Remarks function OemToAnsi(const S: String): String; Convert OEM string into an ANSI string. Added in v6.6.0.2 Beta. function OemToWide(const S: String): WideString; Convert OEM string into a WideString. Added in v6.6.0.2 Beta. function AnsiToOem(const S: String): String; Convert ANSI string into an OEM string. Added in v6.6.0.2 Beta. function WideToOem(const S: WideString): String; Convert WideString into an OEM string. Added in v6.6.0.2 Beta. Basic Conversion Function Remarks function BoolToStr(B: Boolean): String; Convert boolean variable into a string. Returns "True" or "False" string value. function IntToStr(Value: Integer): String; Converts an integer to a string. The following assumptions are correct: • • IntToStr(123) = '123' • • IntToStr(0123) = '123' • IntToStr(123) <> '0123' Note: Be cautious of supplying Int64 type as a parameter as it will be type casted to Integer, which significantly reduces the range of possible values (refer to Types for more information). You can use FormatFloat function to convert Int64 values to a string without a loss of range. function Int64ToStr(Value: Int64): String; Same as IntToStr but takes in Int64 typed parameter. function StrToInt(const S: String): Integer; Converts a string to an integer. The following equalities are correct: • • StrToInt('123') = 123 • • StrToInt('123') = 0123 • • StrToInt('0123') = 123 Warning: An error will occur if the parameter to this function cannot be converted to an integer!
  • 61. Functions 58 function StrToInt64(const S: String): Int64; Same as StrToInt but returns Int64 typed result. function StrToIntDef(const S: String; const Default: Integer): Integer; Behaves like StrToInt function, but instead of producing an error on incorrect input function allows the Default value to be specified, which will be returned if the input cannot be converted to an integer. function StrToInt64Def(const S: String; Default: Int64): Int64; Same as StrToIntDef but operates with Int64 type. function TryStrToInt(const S: String; out Value: Integer): Boolean; Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike StrToInt. Returns False if conversion operation has failed. function FloatToStr(Value: Extended): string; Converts supplied floating point value to its string representation, using default system format. function StrToFloat(const S: string): Extended; Converts supplied string to a floating point value. Warning: An error will occur if the parameter to this function cannot be converted to a floating point value! function StrToFloatDef(const S: string; const Default: Extended): Extended; Behaves like StrToFloat function, but instead of producing an error on incorrect input function allows the Default value to be specified, which will be returned if the input cannot be converted to a floating point value. function FormatFloat(const Format: string; Value: Extended): string; Converts supplied floating point value to its string representation, using user specific Format. Check floating point format specifiers below for more information. function DateToStr(D: TDateTime): String; Converts a date to a string, using system format for the short date, for example: dd/mm/yyyy. function StrToDate(const S: String): TDateTime; Converts a date string to a proper TDateTime value, using system format for the short date, for example: dd/mm/yyyy. function IntToHex(Value: Integer; Digits: Integer): String; Converts an integer to its hexadecimal representation. Here are samples: • • IntToHex(1234, 1) = '4D2' • • IntToHex(1234, 8) = '000004D2' function HexToInt(const HexNum: String): Integer; Converts a hexadecimal value to its decimal representation. Warning: An error will occur if the parameter to this function cannot be converted to an integer! function HexToIntDef(const HexNum: String; Default: Integer): Integer; Behaves like HexToInt function, but instead of producing an error on incorrect input function allows the Default value to be specified, which will be returned if the input cannot be converted to an integer. function Ord(X: Char): Byte; Return an ordinal value (byte representation) of a character. function Chr(X: Byte): Char; Return a character by its ordinal value (byte representation). Floating point format specifiers Specifier Represents 0 (zero) Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string. # (hash) Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string. . (dot) Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored. , (comma) Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.
  • 62. Functions 59 Date and Time Function Remarks function Date: TDateTime; Returns the current system date. function Time: TDateTime; Returns the current system time. function Now: TDateTime; Returns the current system date and time. function EncodeDate(Year, Month, Day: Word): TDateTime; Generates date value for the specified Year, Month, Day. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid. function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime; Generates time value for the specified Hour, Min, Sec, MSec. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid. function EncodeDateTime(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime; Generates date-time value for the specified components of date and time. Similar to EncodeDate and EncodeTime. Added in v6.2.0.5 Beta. function TryEncodeDate(Year, Month, Day: Word; var Date: TDateTime): Boolean; Behaves exactly like EncodeDate function, except this function returns TRUE or FALSE depending on the success of the operation. If operation was successful, function will return TRUE and the generated date value will be written in the Date variable. function TryEncodeTime(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; Behaves exactly like EncodeTime function, except this function returns TRUE or FALSE depending on the success of the operation. If operation was successful, function will return TRUE and the generated time value will be written in the Time variable. function TryEncodeDateTime(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean; Behaves exactly like EncodeDateTime function, except this function returns TRUE or FALSE depending on the success of the operation. If operation was successful, function will return TRUE and the generated date-time value will be written in the ADateTime variable. Added in v6.2.0.5 Beta. procedure DecodeDate(const DateTime: TDateTime; var Year, Month, Day: Word); Extracts Year, Month and Day components from a given DateTime value. procedure DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); Extracts Hour, Min, Sec and MSec components from a given DateTime value. procedure DecodeDateTime(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word); Similar to DecodeDate and DecodeTime but extracts both date and time components at once. Added in v6.2.0.5 Beta. function ComposeDateTime(const Date, Time: TDateTime): TDateTime; Combine date and time components into a single date-time value. Added in v6.2.0.5 Beta. function DateTimeToUnix(D: TDateTime): Int64; Converts D value of type TDateTime to a Unix timestamp. function UnixToDateTime(U: Int64): TDateTime; Converts a Unix timestamp to a value of TDateTime type. function FormatDateTime(const Fmt: String; D: TDateTime): String; This function provides rich formatting of a DateTime value into a string. Date and time format is defined by the Fmt string. function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; Increments a TDateTime variable by a number of years (plus or minus). function IncMonth(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; Increments a TDateTime variable by a number of months (plus or minus). function IncWeek(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; Increments a TDateTime variable by a number of weeks (plus or minus). function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; Increments a TDateTime variable by a number of days (plus or minus).