#1 2010-04-17 12:58

avril
Member
Registered: 2010-04-17
Posts: 2

Delete/Remove all characters after last number in filename

I would like to remove all non-numeric characters after the last number in a file name.

-Before
File 123 - Collection X.txt
File 568935 Various Comments.txt

-After
File 123.txt
File 568935.txt

There is often no delimiter between the number and other text so that won't work.  I think there is a way to do this using regex similar to this post http://www.den4b.com/forum/viewtopic.php?id=838 but I have been unable to figure it out. 

Any help is appreciated, thanks.

Offline

#2 2010-04-17 13:57

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Delete/Remove all characters after last number in filename

Try this with the RegEx rule:

Expression = ^(.*)(\d+).*$

Replace = $1$2

Offline

#3 2010-04-17 15:00

avril
Member
Registered: 2010-04-17
Posts: 2

Re: Delete/Remove all characters after last number in filename

That did the trick, thanks!

Offline

Board footer

Powered by FluxBB