Incrementing numbers in file names

A swapping-ground for Regular Expression syntax

Incrementing numbers in file names

Postby Gabru » Fri Aug 23, 2019 9:24 am

Hello everyone,,
my camera produces two types of file for each photo: one with a .jpg suffix, and one with a .nef suffix

Each filename begins "_imgnnnn" followed by the suffix. "nnnn" is a four-digit number. So, the very first photo is recorded as two files: _img0001.jpg and _img0001.nef.

Usually, when a new memory card is inserted, the first photo on that card produces two files with nnnn that is one greater than that of the last photo taken on the previous card.

BUT when making some adjustments recently, I inadvertantly changed the camera's numbering scheme, and it now resets the counter to 0001 whenever a card is changed.

I didn't notice this until I returned from vacation, and so I have 3 cards with identical file names. I've transferred all three sets of photos onto my PC, each in its own folder. I now want to combine them into one folder - each with a unique number as would have occurred had I not mucked up the configuration! So, I need to make a batch change to the filenames on files from two of the three cardscards.

My question is, what should I put in the "match" and "replace" (and other?) fields of BRU to achieve this?

For example.
Assume that my first card has files named _img0001,nef to _img0134,nef (and similar jpg files), and that the second has files named _img0001.nef to _img0122.nef (ditto). I want the second card's filenames to be changed to _img0135.nef to _img0256.nef

Many thanks
Gabru
 

Re: Incrementing numbers in file names

Postby KenP » Fri Aug 23, 2019 1:46 pm

For the example you've given try this.

1.
Filters(12)
Mask: *.jpg

2.
Select the files.

3.
Remove(5)
From: 4
to: 7

4.
Numbering(10)
Mode: Insert
Start: 0135
Pad: 4
at: 8

5.
Check the last 4 digits of the filename are what you want.

.6
Rename (Do not Reset)

.7
Filter(12)
Mask: *.nef

.8
Select the files (The new file names should be seen in the "New Name" column as soon as the files are selected)

Hope this helps :)
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am

Re: Incrementing numbers in file names

Postby therube » Fri Aug 23, 2019 8:56 pm

Alternative...

5:Remove -> Digits

10:Numbering
- Mode: Suffix
- Start: 0135
- Pad: 4
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Incrementing numbers in file names

Postby therube » Fri Aug 23, 2019 9:08 pm

@Ken, @Admin

---

3. -> looks like that will need to be from: 6 to: 9
Remove(5)
From: 4
to: 7

Why from: 6 <--- ???, if anything, I'd think 5.
This looks to be a bug. (I'm on 3.1, in case that matters.)

---

4.
...
at: 8

Seems like with many values, a value > what is needed acts as an "append".
So in this case, anything 5 or greater would suffice - so 5 or 6 or 8 or 999.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions