Rename to remove variable length filename endings?

Discussion related to "Everything" 1.5.
Post Reply
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Rename to remove variable length filename endings?

Post by wkearney99 »

I run into a situation where some filename often end up with a suffix applied to the filename, and not always the complete string. Sometimes it's truncated, and it's not predictable by total length of the filename.

As in:

"d:\temp\somefilename1 with a variable string suffix.txt"
"d:\temp\somefilename2 with a variable string suff.txt"
"d:\temp\somefilename3 with a variable stri.txt"
"d:\temp\somefilename3 with a v.txt"

Any suggestions on ways to find these, and then a rename to remove the suffix?
therube
Posts: 5723
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename to remove variable length filename endings?

Post by therube »

With a search of:
100,000 sample copy
I get files like:
.
Everything - Rename removing noise.png
Everything - Rename removing noise.png (7.89 KiB) Viewed 3095 times
.

The Old format: has "noise", copy copy copy or what not.
Simply exclude those unwanted parts from the New format: setting.
In this case, (1%1) represents the 127..122 number, which you want, so you want to keep that.
All else is extraneous & will be removed.

In your case, it would show something similar to,
somefilename%1 %2
& you would want to keep
somefilename%1, removing <sp>%2 (& anything that may or may not follow) in the New format: setting.

Should do the job.
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Re: Rename to remove variable length filename endings?

Post by wkearney99 »

I should not have used the 1,2,3 endings on the names, that was just lazy example-making on my part. Most will only have all or some portion of the unwanted suffix and no otherwise consistent marker in the desired source filename.

I'm thinking a short start sequence of the unwanted string might be workable. I don't have a large enough sampling (due to past manual bulk re-naming efforts using incrementally shortened strings).
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Re: Rename to remove variable length filename endings?

Post by wkearney99 »

I'm sure I'm not the only one that starts feeling existential dread when we realize, shit, this is a job probably best done with a regex.... and I suck at regex.

"%1 with a variable string%2.txt"
%1.txt

This cuts things down a bit, looking for just the start of the unwanted suffix, putting the rest in %2 and anchoring with the .txt extension.

or

"%1 with a partial stri%2.%3
%1.%3

Where it'd search for just a part of the string, put "the rest" up until the . into %2 and then not use it.

I could also search with the ext: parameter to include only certain filetypes.
Post Reply