An Easy one for you...

A swapping-ground for Regular Expression syntax

An Easy one for you...

Postby slowreader87 » Fri Mar 01, 2019 4:33 pm

I have some jpg scans of a book which are just out of sequence. Can someone give me the right usage of BRU to make this simple adjustment? I feel it's a RegEx but have minimal experience in them.

I just want to add 2 to whatever the end of last file name was. So Book Vol 4_25.jpg becomes Book Vol 4_27.jpg and so on for all the files into the hundreds.

Any help greatly appreciated!
slowreader87
 
Posts: 2
Joined: Fri Mar 01, 2019 4:25 pm

Re: An Easy one for you...

Postby therube » Sat Mar 02, 2019 1:21 pm

I would think that could be done using JavaScript renaming...


-------


without testing...
i'm thinking...
pseudo-code...


first
10:Numbering
Code: Select all
Mode:  Prefix
Start:  27
Separator:  ^  (some "unique" character, if you will)


> Book Vol 4_25.jpg
> 27^Book Vol 4_25.jpg
(This also allows you to visually compare things; i.e. 27->25, 28->26...)


then
1:Regex
Code: Select all
Match: (.*^)(.*_)
Replace: \2 \1

(not sure offhand if a ^ would need to be escaped?)

> 27^Book Vol 4_25.jpg
> Book Vol 4_27^.jpg


then
3:Replace
Code: Select all
Replace: ^
With: <nul>
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: An Easy one for you...

Postby Admin » Mon Mar 04, 2019 2:33 am

If you have a commercial license for BRU you can use Javascript renaming ....
parse the number after the last _ and then increment of 2
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: An Easy one for you...

Postby slowreader87 » Mon Mar 04, 2019 10:17 am

I realised later that night that it's not that straightforward since you do have to parse the number before you can increment it and re-add it to the file name. Sadly I don't have the BRU paid license but have gone the JS route anyway and instead using Node to process a script which renames the files.

Thanks for the tips anyway. I have found the free version useful in other situations!
slowreader87
 
Posts: 2
Joined: Fri Mar 01, 2019 4:25 pm

Re: An Easy one for you...

Postby Admin » Tue Mar 05, 2019 12:20 am

8)
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions