How to strip leading numbers, spaces, - from filename

Bulk Rename Utility How-To's

How to strip leading numbers, spaces, - from filename

Postby timecheck00 » Mon Jan 15, 2024 1:56 am

I have many music mp3 files that have track number at the beginning of the filename:
for example:

007 - Chuck Berry - Johnny B. Goode.mp3
01 - Fisherman's Blues.mp3

I use the Regex Box 1 V2 ^[0-9 -]{1,4}

That will select the 007 and drop it, but ignores the 01 Fish...

I don't know how to say look at up to 4 positions from the beginning

Thanks for any suggestions. I did a search on leading but didn't find enough to help
timecheck00
 
Posts: 4
Joined: Mon Jan 15, 2024 1:25 am

Re: How to strip leading numbers, spaces, - from filename

Postby Admin » Mon Jan 15, 2024 2:53 am

Hi, this one

^[0-9]{1,4}<sp>-<sp>

where <sp> is a "blank space"

catches and drops both

007<sp>-<sp>
and
01<sp>-<sp>
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to strip leading numbers, spaces, - from filename

Postby timecheck00 » Mon Jan 15, 2024 4:45 am

The ^[0-9]{1,4}<sp>-<sp> did not do it. With that, it no longer selected the 007 -
There is also a third case I want to match
01 songname
timecheck00
 
Posts: 4
Joined: Mon Jan 15, 2024 1:25 am

Remove lead numbers, then spaces and hyphens

Postby Luuk » Mon Jan 15, 2024 6:45 am

Admins suggestion does properly conduct both of the original samples ('007 - ' and '01 - ').
It will conduct any name starting with 1-4 digits, followed by the separator string of ' - '.
If needing space as an alternate separator, it might be easier using something like...
^\d+[- ]+
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to strip leading numbers, spaces, - from filename

Postby timecheck00 » Tue Jan 16, 2024 12:57 am

I will try to attach or insert a screen capture of what I tried:
Putting it out in Google Drive: https://docs.google.com/document/d/e/2PACX-1vSB6xyMAYu5IUGaS-DDyO6quBNsPRjdLOoQbHynEe3NMVEcDGIP1F2PrkzbceSvINDM81m-E1ASGdIJ/pub

It shows the admin suggested regex and the result
timecheck00
 
Posts: 4
Joined: Mon Jan 15, 2024 1:25 am

Re: How to strip leading numbers, spaces, - from filename

Postby Admin » Tue Jan 16, 2024 2:32 am

Hi, <sp> in my example means ' ' (= a space), not literally <sp>

So
<^[0-9]{1,4} - >
without < >
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to strip leading numbers, spaces, - from filename

Postby timecheck00 » Tue Jan 16, 2024 8:17 am

Thank you!
timecheck00
 
Posts: 4
Joined: Mon Jan 15, 2024 1:25 am


Return to How-To


cron