-
Replace Dots with Spaces, except when surrounded by numbers:
Here's a simple Rename question that comes up sometimes (and requires an unexpectedly complex answer):
Zippo came up with the solution in his thread:
Old Name:
(.*)(([^0-9])\.|\.([^0-9]))(.*\..*)#
New Name:\1\3 \4\5
Type:Regular ExpressionsOr, if you want to make a button instead of using the Rename dialog:
@NoDeselect Rename REGEXP PATTERN="(.*)(([^0-9])\.|\.([^0-9]))(.*\..*)#" TO="\1\3 \4\5"[/code]With Opus 12 you can simplify this slightly, as the ignore extension option means you don't have to worry about preserving the last dot. As a bonus, it now works properly with folder names:
Old Name:
(.*)(([^0-9])\.|\.([^0-9]))(.*)#
New Name:\1\3 \4\5
Type:Regular Expressions
Ignore ExtensionsYou could probably also simplify it using regex asserts, or using a script, but the above works fine as-is.
-
Add spaces around dash (-) characters and collapse multiple spaces:
Another solution by Zippo from the same thread. Here's how he described it: This flanks '-' characters with a space character on each side if the space character does not already exist. Additionally, multiple space characters are reduced to only one.
(Note that there are two spaces near the end of the Old Name string.)
Old Name: (.*)(([^ ])(-)|(-)([^ ])| )(.*)# New Name: \1\5\3 \4\6\7 Type: Regular ExpressionsOr, as a button:
@NoDeselect Rename REGEXP PATTERN="(.*)(([^ ])(-)|(-)([^ ])| )(.*)#" TO="\1\5\3 \4\6\7" -
Add spaces around numbers:
This is derived from the example above.
Old name:
(.*)(([^0-9 ])([0-9]+)|([0-9]+)([^0-9 ]))(.*\..*)#
New name:\1\3\5 \4\6\7
Type:Regular ExpressionsOr, as a button:
@NoDeselect Rename REGEXP PATTERN="(.*)(([^0-9 ])([0-9]+)|([0-9]+)([^0-9 ]))(.*\..*)#" TO="\1\3\5 \4\6\7"