Space Before Number

A swapping-ground for Regular Expression syntax

Space Before Number

Postby piattobbaratto » Fri May 17, 2019 1:16 am

How can I add a space before a single digit? I need to rename a huge amount of sound effects but I can't figure out a way without messing with each other.
Long story short, I would like to turn all the variants (1-2-3...) in (01-02-03...) adding a space before or after.

Example:
Male 01 Die1
Male02 Die2
Male 03 Hurt 01
Foot Dirt 2 Jump3
91Firebird Door Open2
69Mustang Rev4

Goal:
Male 01 Die 01
Male 01 Die 02
Male 03 Hurt 01
Foot Dirt 02 Jump 03
91 Firebird Door Open 02
69 Mustang Rev 04
piattobbaratto
 
Posts: 6
Joined: Fri May 17, 2019 1:01 am

Re: Space Before Number

Postby Admin » Fri May 17, 2019 2:26 am

Do you have a commercial license for BRU? If you do then with Javascript we can probably write a small script to handle this.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Space Before Number

Postby Admin » Fri May 17, 2019 2:27 am

- Find digit
- If character before not 0 add 0. If character before not space add space.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Space Before Number

Postby therube » Fri May 17, 2019 3:30 am

Two (or more) runs, perhaps.
(I've spaced out the Replace: for readability.)



Find the (first ?) single digit & pad it.
1:RegEx
Code: Select all
Match:  (.*?\D)(\d)(\D.*)
Replace:  \1   0\2   \3

Code: Select all
02 Links 2 3 4 Rammstein.mp3
02 Links    02    3 4 Rammstein.mp3

(Actually thinking you could just do consecutive 'Rename' without changing anything & that would take care of '2' & then '3' & then '4'.)


Find the (last ?) single digit (other then at the end of the filename) & pad it.
1:RegEx
Code: Select all
Match:  (.*\D)(\d)(\D.*)
Replace:  \1   0\2   \3

Code: Select all
02 Links 2 3 4 Rammstein.mp3
02 Links 2 3    04    Rammstein.mp3



Find a single digit at the end & pad it.
1:RegEx
Code: Select all
Match:  (.*\D)(\d)$
Replace:  \1   0\2

Code: Select all
00-Turneja 2005 CD1.m3u
00-Turneja 2005 CD   01.m3u

(Ages ago I came across this midi, gulpembe.mid [Baris Manco], & man, that just hit me right. Bijelo Dugme kind of follows in the same path.)


I'd think there would be some cases where things would break?
(Other places mentioned look backs & other constructs I'm not really familiar with.)
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Space Before Number

Postby piattobbaratto » Fri May 17, 2019 5:57 am

therube wrote:Two (or more) runs, perhaps.
(I've spaced out the Replace: for readability.)



Find the (first ?) single digit & pad it.
1:RegEx
Code: Select all
Match:  (.*?\D)(\d)(\D.*)
Replace:  \1   0\2   \3

Code: Select all
02 Links 2 3 4 Rammstein.mp3
02 Links    02    3 4 Rammstein.mp3

(Actually thinking you could just do consecutive 'Rename' without changing anything & that would take care of '2' & then '3' & then '4'.)


Find the (last ?) single digit (other then at the end of the filename) & pad it.
1:RegEx
Code: Select all
Match:  (.*\D)(\d)(\D.*)
Replace:  \1   0\2   \3

Code: Select all
02 Links 2 3 4 Rammstein.mp3
02 Links 2 3    04    Rammstein.mp3



Find a single digit at the end & pad it.
1:RegEx
Code: Select all
Match:  (.*\D)(\d)$
Replace:  \1   0\2

Code: Select all
00-Turneja 2005 CD1.m3u
00-Turneja 2005 CD   01.m3u

(Ages ago I came across this midi, gulpembe.mid [Baris Manco], & man, that just hit me right. Bijelo Dugme kind of follows in the same path.)


I'd think there would be some cases where things would break?
(Other places mentioned look backs & other constructs I'm not really familiar with.)


Thanks a lot for your time, looks like it's working so far. I keep you updated!
piattobbaratto
 
Posts: 6
Joined: Fri May 17, 2019 1:01 am

Re: Space Before Number

Postby piattobbaratto » Fri May 17, 2019 6:00 am

Admin wrote:Do you have a commercial license for BRU? If you do then with Javascript we can probably write a small script to handle this.


Yes, I do! That would be awesome. It would make my life easier since the number of files it's unthinkable.
I look forward to testing the script, thanks in advance!!
piattobbaratto
 
Posts: 6
Joined: Fri May 17, 2019 1:01 am

Re: Space Before Number

Postby Admin » Fri May 17, 2019 6:58 am

Could you please contact us : https://www.bulkrenameutility.co.uk/Contact.php

thanks!
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions


cron