Incrementing numbers in file names

A swapping-ground for Regular Expression syntax

Incrementing numbers in file names

Postby Gary38 » Sat Mar 27, 2010 6:18 pm

Hi, 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
Gary
Gary38
 
Posts: 2
Joined: Sat Mar 27, 2010 5:57 pm

Re: Incrementing numbers in file names

Postby Stefan » Sat Mar 27, 2010 7:42 pm

Gary38 wrote: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
Gary


Hi Gary,

the trick is to select only one file type at time, then the second one.
Then remove the current numbering and do an new numbering started at 0135.


First try this with test files, not your real files.
Copy a few *.jpg and *.nef files to an temp folder and try this:

FROM:
named _img0001.nef
named _img0001.jpg
TO:
named _img0135.nef
named _img0135.jpg

STEP 1
1.) show the folder with the files from the second card (or the temp folder)
Select one or more files to see as preview what happens while doing the following.

2.) Selection(12) Filter *.NEF (click once into the files pane, or de-select and select [X] Files to see the effect)
named _img0001.nef
3.) Remove(5) Last 4
named _img.nef
4.) Numbering(10) Suffix, Start 135, Pad 4
named _img0135.nef
If you are satisfied what you see, press at [Rename]

STEP 2
5.) Selection(12) Filter *.JPG
named _img0001.jpg
Press CTRL+A to select all files to see an preview
named _img0135.jpg
If you are satisfied what you see, press at [Rename]

HTH? :D
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Incrementing numbers in file names

Postby Gary38 » Sat Mar 27, 2010 8:04 pm

Stefan

This works perfectly. Thank you.

I downloaded BRU today and spent 3 hours researching "regular expressions" on the web and trying all sorts of things. It was fun, but I knew I'd hit a brick wall. I can now get back to my photos - with a big smile on my face!

Thanks again,
Gary
Gary38
 
Posts: 2
Joined: Sat Mar 27, 2010 5:57 pm


Return to Regular Expressions