Multi-rename tool: how to remove first N or last N chars

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
thepearlsmaster
Junior Member
Junior Member
Posts: 8
Joined: 2015-07-21, 11:01 UTC

Multi-rename tool: how to remove first N or last N chars

Post by *thepearlsmaster »

Hi there,

it would be nice if you could remove first N or last N chars from filename...

I only found an option to select a range of chars from filename but nothing regarding what I said above.

What do you think about that?
User avatar
Dalai
Power Member
Power Member
Posts: 7310
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

It's in the help:
TC help, opened with F1 in the MRT dialog wrote:[...]
[N-8,5] 5 characters starting at the 8-last character (counted from the end of the name)
[N-8-5] Characters from the 8th-last to the 5th-last character
[N2--5] Characters from the 2nd to the 5th-last character
[N-5-] Characters from the 5th-last character to the end of the name
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups
User avatar
Stefan2
Power Member
Power Member
Posts: 3038
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Multi-rename tool:remove first N or last N chars

Post by *Stefan2 »

Hi and welcome.
thepearlsmaster wrote:it would be nice if you could remove first N or last N chars from filename...
What Dalai says.



Examples:

Rename mask: file name

Remove first 3 chars from file name (start at 4th): [N4-]
TOTALCMD.EXE >> ALCMD.EXE

Remove last 3 chars from file name (first till 4th-last): [N1--4]
TOTALCMD.EXE >> TOTAL.EXE

Remove first 3 chars AND last 3 chars from file name: [N4--4]
TOTALCMD.EXE >> AL.EXE




HTH?
joe910
Junior Member
Junior Member
Posts: 4
Joined: 2009-02-23, 03:05 UTC
Location: Peoria, IL USA

Post by *joe910 »

Thank you for pointing this out. I am a long time user but did not know this.
User avatar
Ovg
Power Member
Power Member
Posts: 650
Joined: 2014-01-06, 16:26 UTC
Location: MOW

Post by *Ovg »

2joe910

Open TC, then press F1 key. Read It. There are many interesting things, trust me :mrgreen:
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 9.51 x64, Windows 7 SP1 x64
thepearlsmaster
Junior Member
Junior Member
Posts: 8
Joined: 2015-07-21, 11:01 UTC

Post by *thepearlsmaster »

Wonderful! I didn't notice all these examples in the help.

Thank to all of of you for your suggestions.
User avatar
Phred
Senior Member
Senior Member
Posts: 312
Joined: 2009-06-16, 15:24 UTC
Location: SEAu

Re: Multi-rename tool: how to remove first N or last N chars

Post by *Phred »

[this thread is the only result for 'delete last character, so, to expand the theme-]

How can you make it conditional, e.g. if the last character is a space, delete it?
I suspect it's a job for regex.
Thx.
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors token for the title-bar so we can display that we have contributed further.
User avatar
Stefan2
Power Member
Power Member
Posts: 3038
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Multi-rename tool: how to remove first N or last N chars

Post by *Stefan2 »

Phred wrote:
2019-04-11, 09:35 UTC
How can you make it conditional, e.g. if the last character is a space, delete it?
Yes, try RegEx

Search: \s$
Replace: <Clear>
[_]E
[x]RegEx



Search: \s$ ==> the last character is a space
Search: \s+$ ==> the last few characters (one-or-more) may be a space
Instead of the RegEx Meta char "\s", you can also enter a real space sign.

You can try this with any sign, like delete only the last 'e' by using: Search: e$

Press F1-key in MRT and then click on "RegEx      Now supports regular expressions." if you want to know more about.



HTH?
User avatar
Phred
Senior Member
Senior Member
Posts: 312
Joined: 2009-06-16, 15:24 UTC
Location: SEAu

Re: Multi-rename tool: how to remove first N or last N chars

Post by *Phred »

[kisses] :)

That's certainly it. [space] and [end of line] ==> \s and $ ==> \s$
I've learned that RegEx is a duo: Search for something and Replace the result with something else.

I note that [_] is a blank, reset, tick-box, and [x] is a chosen, set, box.
I'm curious that [_] E is required so as not to refer to the file(s) extensions. Hovering over the E reports 'Replace also in file extensions, while clearing it makes the dialog box refer to only the filename; setting it includes the extension - therefore, IMO, the hover-prompt is WRONG: it should say:
'AND find & replace also in file extensions'. Setting it refers to BOTH, not exclusively the filename OR (xor) the extension: the condition has to qualify for BOTH parts of the filename.extension for the action to obtain.
Comment Author Ghisler?
I also note that on my screen the E is closer the to RegEx tick-box than to its own.*

I'm a 'small steps' learner, I'm afraid, taking a feature and learning how to use it with examples, then expanding that knowledge with another related small step.
The TC RegEx Help 'dictionary' is a bit too bland for me. I once saw a site that gave realtime results of typed expressions, but a gradual explanation and testing process with examples and over-teaching would have been more welcome. A slow tutorial I shall find.

Does That Help? It certainly does.
Yours in persistence,
Thx.
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors token for the title-bar so we can display that we have contributed further.
Post Reply