Multi-Rename Tool - "." > "_"

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
tridy
Junior Member
Junior Member
Posts: 92
Joined: 2003-11-27, 07:51 UTC
Location: Еurоpе

Multi-Rename Tool - "." > "_"

Post by *tridy »

Hej.

I have tried to search on the forum and I haven't seen any problems like that. So, from time to time I get a bunch files like that:

Lyrics.I.Like.It.Like.That.txt
Lyrics.Listen.To.Your.Heart.txt
Lyrics.One.Wish.txt
Lyrics.The.Look.txt

and my task is to replace "." with "_" but leave the extension. If i use the multi-rename tool, it will replace .txt with _txt as well. so, I would get:

Lyrics_I_Like_It_Like_That_txt

instead of:

Lyrics_I_Like_It_Like_That.txt

So, is it possible to tell the multi-rename tool to multi-rename only the filename and leave the extension alone?

It is possible to write a regular expression, calculating the position of the last "." (it's not -3 because the extension might be longer or shorter than 3 symbols) and skip the part after this position but maybe ithere is something simplier to use that I don't know?

Thanks
[tridy]
License #: 79539
User avatar
gbo
Senior Member
Senior Member
Posts: 329
Joined: 2005-03-31, 19:58 UTC
Location: Lausanne (Switzerland)

Post by *gbo »

Gil
Licence #17346

90% of coding is debugging. The other 10% is writing bugs.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

tridy,
The easy way:

Code: Select all

        Name: [N]
   Extension: #[E]
  Search for: .|_#
Replace with: _|.
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
gbo
Senior Member
Senior Member
Posts: 329
Joined: 2005-03-31, 19:58 UTC
Location: Lausanne (Switzerland)

Post by *gbo »

Nice way to do it 8)
Gil
Licence #17346

90% of coding is debugging. The other 10% is writing bugs.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Have you tried it? For me it doesnt work at all :oops:
I switched to Linux, bye and thanks for all the fish!
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

2SanskritFritz

Hm, works fine for me. Nice tip, Hacker!
User avatar
tridy
Junior Member
Junior Member
Posts: 92
Joined: 2003-11-27, 07:51 UTC
Location: Еurоpе

Post by *tridy »

Hacker wrote:tridy,
The easy way:

Code: Select all

        Name: [N]
   Extension: #[E]
  Search for: .|_#
Replace with: _|.
HTH
Roman
Well, this will work for the most of the time, unless you have # in the file name, in case of C# for instance or something similar. So, you need to make sure it's not a commonly used symbol. But I will stick to the one that you wrote.


I thought before about having something with regular expressions:

Code: Select all

note: using regular expressions
Search for: (\.)([^\.]*)(\.)
Replace with: _$2$3
but that will do it only one time and then I will need to do it as many times as there are "." in the filename.

I tried to do it so there will be just a replacement for the "." except for the last one in the name but I couldn't do it. If I will come up with something else, I will post it.

Thanks for your help guys.
[tridy]
License #: 79539
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

gbo, StickyNomad,
Thanks. ;) 8)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
gbo
Senior Member
Senior Member
Posts: 329
Joined: 2005-03-31, 19:58 UTC
Location: Lausanne (Switzerland)

Post by *gbo »

2Sans

It works fine here, I also made a variant (Replace . by Space )

Name: [N]
Extension: #[E]
Search for: .| #
Replace with: |.

Do not forget to add a space in last line [SPACE]|.


MRT Screenshot
Gil
Licence #17346

90% of coding is debugging. The other 10% is writing bugs.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Eeerm, I left RegEx accidentally turned on :oops:
I switched to Linux, bye and thanks for all the fish!
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

2SanskritFritz

ts, ts, ts. The dessert is canceled for you today. :wink:
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2StickyNomad
I eat RegEx for dessert :-)
I switched to Linux, bye and thanks for all the fish!
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

2SanskritFritz
:lol: :lol:
User avatar
white
Power Member
Power Member
Posts: 5979
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

tridy wrote: I tried to do it so there will be just a replacement for the "." except for the last one in the name but I couldn't do it. If I will come up with something else, I will post it.
If you can assume there is always a dot in the file name besides the one separating the file name and extension, you can use:

Code: Select all

Search for:   \.([^.]*\.[^.]*)$|\.
Replace with: _$1

(RegEx checked)
Otherwise I am convinced it is not possible using TC's regular expressions. In future it might become possible if TC's subset of Perl's regular expressions are expanded to include Perl's Zero-width positive lookahead assertion (?=...).
User avatar
kwanbis
Junior Member
Junior Member
Posts: 68
Joined: 2006-11-06, 21:30 UTC

Post by *kwanbis »

Thanks for the tips, but this is a simple to fix design flaw.

Or how many of us want to replace the dot separating the extension?

The truth is, that i'm sure that MRT is using a function call like:

newname = ReplaceChars(filename+"."+extension, fromchars, tochars)

and it should be a matter of simply changing it to

newname = ReplaceChars(filename, fromchars, tochars)+"."+ReplaceChars(extension, fromchars, tochars)

Simple fix. And it would be the EXPECTED behavior.
Post Reply