Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
As part of research for a book on vintage port, I am taking many photos of menus and pages of cellar books. Many. The camera is a DSC-W180, which names files DSC0nnnn.JPG (eg, DSC01234.JPG). Alas, the camera can’t count past 9999, it then going back to 1. Whoops.

Please, is it easy to add a button/command/keystroke somewhere in or near the Finder that does something like the following pseudocode (where ‘•’s represent tabbed indentation):

• For All Selected Files
•• If FileName is of the format “DSC0nnnn.JPG” Then
••• If FileCreationDate is >= 21:59 on Sun 26 Sept 2010 Then
•••• Rename file to “DSC1nnnn.JPG”.
••• End If
•• End If
• End For All

?

OSX 10.6.4; iMac 5,2; 1.83Ghz. Xcode 3.2.4 is installed.

Thank you kindly.
 

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
Thank you. I will give the former a test.

However, it does feel that AppleScript really ought to be able to do this easily. It has advantages:
• I can be confident that the if statements, checking that the files are really those that I want renamed, are actually executed.
• The result is light, and easily and precisely changed.
 

numlock

macrumors 68000
Mar 13, 2006
1,590
88
How many pictures are you talking about?

You want the new filename to be 5 digits and have the pics renamed based on their creation date?
 

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
Files, over multiple folders, run:
DSC00001.JPG
DSC00002.JPG

DSC09998.JPG
DSC09999.JPG (file created 21:58 on Sun 26 Sept 2010)
DSC00001.JPG (file created 21:59 on Sun 26 Sept 2010)
DSC00002.JPG


So there are two ‘DSC00001.JPG’s. It seems natural to remove the duplication by changing the lead zero to a one. But, to prevent careless error, this should happen only to files with names in this format, and only to those of the second lap (i.e., after the lapping date).

How many? A one-day visit to an archive can produce 500 pictures. The plan is that they are dragged to a folder, command-A, button/keypress/menu, and it’s done. The checks are in case a careless error has selected files in the wrong folder.
 

Dave00

macrumors 6502a
Dec 2, 2003
883
106
Pittsburgh
You really want A better finder rename. I've found it essential for organizing my photo files. There are many ways to organize the files, using data from the files themselves. For instance, you can name the files based on the date they were taken and then numerically ordered - 10-4-10-0001, 10-4-10-0002, etc. That sounds like what you'd need for your purposes, and you wouldn't run the risk of accidentally overwriting files like you might with writing your own code.
 

BertyBoy

macrumors 6502
Feb 1, 2009
326
0
What about some sort of Terminal command -

Code:
for i in $( find . -name 'DSC0*.JPG' -newer images/2010.08.06/DSC09999.JPG -type f -print ); do mv $i $( echo $i | sed 's/DSC_0/DSC_1/' ); done

Of course, you'd have to fill in the pathname to the DSC09999.JPG file. And the "-type f" and "-print" aren't really necessary, but it plays safe, in case you hit a directory called 'DSC0xxxx.JPG'.

Practice in a sample directory to get confident with it before using for real. Then keep it for when you need to prefix the files with a '2' or '3', etc.
 

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
Not what I had envisaged, but cool nonetheless. Thank you.

Just to be safe, can “DSC0*.JPG” be replaced with the more precise DSC0nnnn.JPG form?

And can there be an explicit constant date for the ‘newer’ thing?
 

BertyBoy

macrumors 6502
Feb 1, 2009
326
0
Just to be safe, yes. Replace the asterisk with [0-9][0-9][0-9][0-9]

For the -newer option, you're safer using the existing format, and no, I don't know of a way to substitute a specific time.

I have had similar issues in the past when working with multiple cameras. so I had maybe 2,500 images using DSC_00001.JPG through to DSC_00400.JPG. A nightmare in the past also when I changed CF cards and battery, the counter would reset to DSC_00001.JPG. At -30C I'd get about 6 shots off before the battery would get too cold to operate, so into my pocket, warm battery out and in, and another 6 shots if I was quick. 16GB CF cards are the best invention ever.
 

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
Fabulous. Thank you again.

I have long complicated pathnames, and don't want to guarantee that picture 9999 never moves. Can it be replaced with a UNIX time of 1285538340?

Edit: this suggests something like “-newer -t 201009262159”. I’m regretting never having mastered UNIX.
 

BertyBoy

macrumors 6502
Feb 1, 2009
326
0
Well you could always replace the absolute path of DSC09999.JPG with another subshell which does a find looking for DSC09999.JPG, ie.
Code:
$(find . -name 'DSC09999.JPG' -type f -print)
and I though of that first, but what if there are 2 files with that name ? And that will happen when you get to the 19,998th picture, ie. DSC09999.JPG before you rename it with this script.

Did also consider your idea about "touch"ing an empty file with the desired modification date, put somewhere in the higher levels of your photograph directory hierarchy. But then I thought that you have the first DSC09999.JPG anyway. If you'd feel happier,
Code:
touch -t 201009262159 photo.marker1
and use that instead of the reference to DSC09999.JPG.

Remember to update it or create another, ie. photo.marker2, when you get to 19,998+ photos.

There is a danger in the script in that once you get above 19,998 photos, you may have some you wish to rename to DSC1nnnn.JPG and some DSC2nnnn.JPG.
If you create the 2nd marker with the appropriate date and time and run that command first it won't be an issue, all the DSC0nnnn.JPGs that need to be renamed to DSC2nnnn.JPG will have been done, and the run of the original command (to rename to DSC1nnnn.JPG) will only pick up those still named as DSC0nnnn.JPG.
I'm also worried about the time accuracy you use for creating the marker files. Could be that the marker file ends up with a modification time just fractions of a second before the DSC09999.JPG it is copied from and you end up renaming DSC09999.JPG to DSC19999.JPG when you didn't intend to.
 

jdaw1

macrumors newbie
Original poster
Oct 2, 2010
8
0
London
My preference is to use a process that I understand. That allows me to vary it, if needed, and to recognise potential and possible failure modes. Applescript is easy to read—hence my originally suggesting that.

Terminal commands, though powerful, are cryptic. I don’t know what is happening.

So Automator: Filter by Date Created → Find “DSC0” Replace “DSC1”. It’s not quite perfect, but my having to drag files onto it acts as a pre-selection. Doing that: thank you for the suggestion.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.