Request help from a scriptor

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Request help from a scriptor

Post by aurumdigitus »

Want to use Rename Special with a RegExp. Expression one would remove the first X characters of a file name(s). Expression two would remove the last X characters from the file(s) name.

(In my gut think I may have requested this many iterations of XY ago but now am unable to find the code. :oops: )

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Request help from a scriptor

Post by TheQwerty »

I'm not sure if this old script I posted actually still works but it could handle those two cases when it did: http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=2316

Either way the regex patterns in it should still be good, though it's possible they could be improved (I've learned a bit since then). ;)


In simplest terms...
This will remove 2 characters from the beginning.

Code: Select all

^.{2} > 
Similarly, this will remove 3 from the end of the full filename.

Code: Select all

.{3}$ > 
But you probably want to remove them from the base name before the extension so you'd want something like

Code: Select all

.{3}(\.[^.]+$) > $1

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Request help from a scriptor

Post by highend »

1.

Code: Select all

^\w{X} > 
2.

Code: Select all

\w{X}(\.[^.]+$) > $1
X = the max number of chars to remove
One of my scripts helped you out? Please donate via Paypal

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Request help from a scriptor

Post by aurumdigitus »

Thanks everyone!

Some time before the sun runs out of hydrogen I try to sit down and learn this RegExp business. :biggrin:

Post Reply