RegExp Rename: Cut numbers from beginning of filename

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
admin
Site Admin
Posts: 66299
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

RegExp Rename: Cut numbers from beginning of filename

Post by admin »

Cut one or more numbers followed by a minus ("-") char from the beginning of the filename:

Code: Select all

version 1: (^\d{1,}-)(.*) > $2
version 2: (^\d+-)(.*) > $2
Examples:

Code: Select all

1-20081015-01.lnk   > 20081015-01.lnk
12-20081015-02.lnk  > 20081015-02.lnk
321-03.txt          > 03.txt
1.lnk               > <Unchanged> 1.lnk
Trivial for RegExp experts but I'm proud I figured it out... :wink:

PS: And here's a tip for newbies. You can run this rename job directly through the Address Bar, using the following "Quick Script":

Code: Select all

::rename "r", "(^\d+-)(.*) > $2", "p"

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

Re: RegExp Rename: Cut numbers from beginning of filename

Post by TheQwerty »

You could even eliminate the second group entirely:

Code: Select all

^\d+- > 
Note: There should be a trailing space on the pattern but it appears the code box is overzealous in trimming..

Post Reply