Advanced Rename: Allow for anchor-less find/replace.

Discussion related to "Everything" 1.5 Alpha.
Post Reply
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Advanced Rename: Allow for anchor-less find/replace.

Post by raccoon »

In the Advanced Rename (as well as Advanced Move to Folder), the Old Format and New Format fields require a left/right anchor variable of %1 (%2, %3.. etc) in order to retain portions of the original object names.

I propose that if no %1 variables are used in the Old Format field, then the operation automatically gets treated as a blanket Find & Replace. Where the substring entered into Old Format is replaced with the substring entered into New Format, as it occurs anywhere in the object name.

For example:
Old: apples
New: oranges

would be the same as having typed:
Old: %1apples%2
New: %1oranges%2

In addition, if the word appears multiple times, it gets replaced multiple times. Example:
Old: .
New: -

This would replace all dots with dashes.

Feature creep: Add an option '[x] Preserve extensions' that is enabled by default.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by NotNull »

For now:

If you enable Regular expressions, you can use
Old Format: apples
New Format: oranges

That will replace all instances of 'apples' with 'oranges'


When you want to replace characters that are part of the regular expression language (
- \ ^ ( ) { } [ ] + . $)
, you need to prefix it with the \ escape character in the Old Format.

So if you want to replace (this) with [that]:
Old Format: \(this\)
New Format: [that]
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by raccoon »

Ah hah. And here I thought regex renames actually needed \1 \2 backrefs.

So yeah, would be cool if the same behavior worked with/without regex patterns.

Thanks.
void
Developer
Posts: 16698
Joined: Fri Oct 16, 2009 11:31 pm

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by void »

I will consider replacing all text in old format with the new format when regex is disabled.
I will consider a [x] Preserve extensions option.

Thank you for the suggestion.

There is a Find and replace dialog on my TODO list.
These options might be better suited towards this dialog.
void
Developer
Posts: 16698
Joined: Fri Oct 16, 2009 11:31 pm

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by void »

Everything 1.5.0.1287a will now replace all occurrences of old format with new format when the old format does not contain a variable (%1 - %9).

Everything 1.5.0.1287a also adds support for detecting _-_ and - separators.
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by raccoon »

I am unfamiliar with the _-_ and - separator detection magic. Could you describe it?
void
Developer
Posts: 16698
Joined: Fri Oct 16, 2009 11:31 pm

Re: Advanced Rename: Allow for anchor-less find/replace.

Post by void »

The multi-file-renamer will look for the following separators (in order of priority) to generate the old format:

Code: Select all

.
 - 
_-_
-
_

This might be useful when the start of the filename doesn't match for all files.

For example:

Album - ArtistA - SongA.mp3
Album - ArtistBB - SongBB.mp3
Album - ArtistCCC - SongCCC.mp3

With the above, Everything will generate the old format as: Album - Artist%1 - %2.mp3
Note the detection of " - " with different artist lengths.
Without this separator matching, Everything would generate the old format as: Album - Artist%1.mp3

The number of separators must match for all files. Otherwise, the separator is ignored.
Post Reply