remove last character with multi-rename tool

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
koekje12
Junior Member
Junior Member
Posts: 7
Joined: 2024-03-07, 10:42 UTC

remove last character with multi-rename tool

Post by *koekje12 »

Dear Forum Members,

I am working on a digital archive pre-ingest, my question is as follows:
How can i remove the '_' that are written at the end of my files?

Current filename:
wico_flyer_03_.txt

Desired filename:
wico_flyer_03.txt

I tried working with the [N] placeholders, but can't figure out how to make them useful for this scenario.
The problem is that there are many, many different filenames that end with a '_', I am looking for an effective, time saving solution.
Would greatly appreciate if you know something to help me out :)!
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: remove last character with multi-rename tool

Post by *Hacker »

Hi koekje12,

Code: Select all

[N1--2]
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
koekje12
Junior Member
Junior Member
Posts: 7
Joined: 2024-03-07, 10:42 UTC

Re: remove last character with multi-rename tool

Post by *koekje12 »

Hello Roman,

Thanks for your reply!
My apologies, I haven't been very clear in my question, there are also many files with no '_' at the end of their name.
Now I end up removing their names as well, is there any function to only remove the last character when it is a '_' ?

Appreciate the help!
Kind regards
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: remove last character with multi-rename tool

Post by *Stefan2 »

FROM:
wico_flyer_03_.txt
wico_flyer_04.txt

TO:
wico_flyer_03.txt
wico_flyer_04.txt


USE:
- select all files
- press Ctrl+M


in MRT:
Search for: _$
Repalce: <Clear>
[_]E
[x]RegEx


Explanation:
- [_]E == Don't work on the file extension but on the base name only
- [x]RegEx == Enable Regular Expression
- Search for "_" at the end of the string ( "$" == regex Line Boundary: match at end of line)
- Replace with nothing (so remove it)




More:
https://www.ghisler.ch/wiki/index.php/Regular_Expressions
https://regex.sorokin.engineer/en/latest/regular_expressions.html
https://regex.sorokin.engineer/de/latest/regular_expressions.html


 
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: remove last character with multi-rename tool

Post by *Dalai »

This should work:

Search for:

Code: Select all

(.+)_$
Replace with:

Code: Select all

$1
[ ] E
[X] RegEx

2Stefan2:
This will replace all underscores, not just the last one.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: remove last character with multi-rename tool

Post by *Stefan2 »

Dalai wrote: 2024-03-07, 11:33 UTC
2Stefan2:
This will replace all underscores, not just the last one.


Thank you, your were right for "_?", but I already had adjusted my mistake (typo) while you were typing :wink:



 
User avatar
koekje12
Junior Member
Junior Member
Posts: 7
Joined: 2024-03-07, 10:42 UTC

Re: remove last character with multi-rename tool

Post by *koekje12 »

Thanks to both of you, it worked :)

Are there any resources where one can learn to use these '(.+)_$' commands?
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: remove last character with multi-rename tool

Post by *Dalai »

2koekje12
When the MRT is open press F1 to open the help and look for regular expressions. There's a dedicated page in TC help about it. Also see the resources linked by Stefan2.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
koekje12
Junior Member
Junior Member
Posts: 7
Joined: 2024-03-07, 10:42 UTC

Re: remove last character with multi-rename tool

Post by *koekje12 »

I see, thank you!
Post Reply