Counter in 'Search and Replace'? (Multi-Rename Tool)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Valery_Kondakoff
Junior Member
Junior Member
Posts: 92
Joined: 2004-06-27, 15:24 UTC

Counter in 'Search and Replace'? (Multi-Rename Tool)

Post by *Valery_Kondakoff »

Hi!

Is it possible to replace a specified text by a counter using 'Search and Replace' in Multi-Rename Tool? (I can't find a way how can I enter the counter in 'Replace With...' field.)

I can give an example: I have some selected files with numbers in their names like this:

test02.txt
01test.txt
te18st.txt

I want to replace all the digits with a counter. What is the best way to perform this? I was thinking about enabling RegExes and entering '\d\d' in 'Search for...' field and a counter in 'Replace with...' filed. But I have no idea how to use the counter in 'Search and Replace'...
CU
VK
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

You can't use the counter there, quite simple.

You can only kill all digits with RegEx and after that add a counter before the file names.

Icfu
This account is for sale
Valery_Kondakoff
Junior Member
Junior Member
Posts: 92
Joined: 2004-06-27, 15:24 UTC

Post by *Valery_Kondakoff »

Hmm... This means, that currently it is impossible to replace the found substring with some placeholder (like counter)? Don't you think this is an area for future improvement?
CU
VK
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

TextPad is able to insert a replacement expression counter (/i), so is it a different syntax?
I switched to Linux, bye and thanks for all the fish!
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3299
Joined: 2003-05-06, 11:46 UTC

Re: Counter in 'Search and Replace'? (Multi-Rename Tool)

Post by *Sir_SiLvA »

Valery_Kondakoff wrote:I can give an example: I have some selected files with numbers in their names like this:
test02.txt, 01test.txt, te18st.txt
And how should the look after rename ?
like test 01.txt, test 02.txt, test 03.txt?

If thats the case I would do it as followed:
Enter in the field Name: "[N] [Caa]"
In the field Search for "\d" (one \d is enough :))
In the field Replace with: "nothing"
Enter and than Press F5
Clear the fields Search for and Replace with
Enter in the field Name: "[N1--4] [C:2]"

(all Strings without(!) " :-))
Hoecker sie sind raus!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

@Valery_Kondakoff:
Hmm... This means, that currently it is impossible to replace the found substring with some placeholder (like counter)? Don't you think this is an area for future improvement?
Of course it is, I have supported two requests for the MRT in the German forum yesterday to extend the functionality like this:
1. ignore the file extension when searching and replacing
2. add a possibility to chain replacements when RegEx is activated like it can already be done using the "normal" search and replace.

http://www.ghisler.ch/board/viewtopic.php?t=7464#59499

Additionally I'd like to do replacements using the plugins for example, endless possibilities if you ask me, the MRT is far from being perfect.

Icfu
This account is for sale
Valery_Kondakoff
Junior Member
Junior Member
Posts: 92
Joined: 2004-06-27, 15:24 UTC

Re: Counter in 'Search and Replace'? (Multi-Rename Tool)

Post by *Valery_Kondakoff »

Sir_SiLvA wrote:And how should the look after rename ?
like test 01.txt, test 02.txt, test 03.txt?
No, in this example I just wanted to replace all available digits with incremented counter. Like this:
test01.txt
02test.txt
te03st.txt etc... - this is just an example of renaming scheme currently impossible by TC.

BTW: IMHO your example will not work, just because if you replace all '\d' with 'nothing' all the files will have the same name (test.txt) which will produce unexpected results as far as I can understand.
CU
VK
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3299
Joined: 2003-05-06, 11:46 UTC

Re: Counter in 'Search and Replace'? (Multi-Rename Tool)

Post by *Sir_SiLvA »

Valery_Kondakoff wrote:BTW: IMHO your example will not work, just because if you replace all '\d' with 'nothing' all the files will have the same name (test.txt) which will produce unexpected results as far as I can understand.
Do you need some glasses ? :D (Filemann? :D)
Why Do you think if written 2 postings above
myself wrote:Enter in the field Name: "[N] [Caa]"
:?:
therefore my example works 100%...

Also I still dont know why someone should want to rename files
from test02.txt, 01test.txt, te18st.txt
to test01.txt, 02test.txt, te03st.txt?

ICFU is it possible to do this job with Oscar's FR?

But I think it would be nice if the Replace-with-box would
support all the [*]-Tags (a [ then would be entered with [[)
Anybody against/for it ?
Hoecker sie sind raus!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

It is possible like this:
1. Copy all filenames to clipboard
2. Paste the filenames in some advanced text editor that supports counters
3. Replace using RegEx:
search for \d+
replace with Counter
4. Copy&paste editor output to Oscar's Renamer, same directory loaded of course
5. Press OK in Oscar's Renamer

Icfu
This account is for sale
Valery_Kondakoff
Junior Member
Junior Member
Posts: 92
Joined: 2004-06-27, 15:24 UTC

Re: Counter in 'Search and Replace'? (Multi-Rename Tool)

Post by *Valery_Kondakoff »

Sir_SiLvA wrote:therefore my example works 100%...
Yes, you are right. I have not noticed the '[N] [Caa]' part of your example.
Also I still dont know why someone should want to rename files
from test02.txt, 01test.txt, te18st.txt
to test01.txt, 02test.txt, te03st.txt?
This was just a quick example. I was trying to illustrate the following problem: from time to time you need to use the regexps and placeholders at the same time. For example, to find a common strings in multiple filenames and add a counter to it. Imagine, that you need to rename these files:

Valery_Birthaday_small.jpg
SmallValeryPic_large.gif
new_pic_of_Valery_small.png

to:

Valery_01_small.jpg
Valery_02_large.gif
Valery_03_small.png

The easyest way is to find a substrings using regexp '.*(Valery).*(.....\..*)' and replace the entire filename with regexp:

Code: Select all

$1_<2-digit counter>_$2
But this is impossible. And this is a problem...
CU
VK
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

4. Copy&paste editor output to Oscar's Renamer, same directory loaded of course
5. Press OK in Oscar's Renamer
Provided you have the same order of files in Oscar and TC.
I switched to Linux, bye and thanks for all the fish!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

True, but you can circumvent that by adding a counter plus unique string in front of each file name in TC before loading it in the editor so even if you change the order later in the external editor you can easily alphabetize it with no problem.

I think the topic starter isn't interested in workarounds anyway, too bad.

Icfu
This account is for sale
deckard
Junior Member
Junior Member
Posts: 80
Joined: 2003-10-10, 09:18 UTC

Post by *deckard »

Valery_Kondakoff wrote:Hmm... This means, that currently it is impossible to replace the found substring with some placeholder (like counter)? Don't you think this is an area for future improvement?
Yes, I'd like to see this feature too. It's quicker than the suggested workarounds.
Post Reply