Page 1 of 1

Request help from a scriptor

Posted: 01 May 2014 20:29
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: )

Re: Request help from a scriptor

Posted: 01 May 2014 20:53
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

Re: Request help from a scriptor

Posted: 01 May 2014 20:54
by highend
1.

Code: Select all

^\w{X} > 
2.

Code: Select all

\w{X}(\.[^.]+$) > $1
X = the max number of chars to remove

Re: Request help from a scriptor

Posted: 02 May 2014 16:25
by aurumdigitus
Thanks everyone!

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