Renaming iPhone photo files

My iPhone has become my “goto” camera. It is always handy and does a fine job. As an old-timer in photography, I feel that after the shutter button is pressed the job is only half done. Post-processing is an essential part of bringing out the best in the image. My “lab work” is done on my laptop. This means, of course, importing the photo files and organizing them along with images from my other cameras.

The photo file names assigned by the iPhone look like this: 20230327_165036028_iOS.heic

There is some sense in that pattern, it goes like this: YYYYMMDD_hhmmssxxx_iOS.heic, where YYYY is the year, MM the month, DD the day, hh the hour, mm the minute, ss the second, xxx fraction of the second, iOS tells that it comes from the Apple phone operating system, and heic is the image format file extension.

These file names are a bit too long for me. I prefer this: LKYYMMDD-hhmmss.heic. Mine start with my initials, then just two digits of the year number, then month and day numbers, the time in hours, minutes, and seconds, the rest before the dot is dropped. Of, course the extension is preserved, since that tells editors how to manage the data. Most photo editor programs, or apps, provide a way for renaming files. My way is to rename them before they every get into an editor.

Here is how I do it

Windows still provides a command line processor that can do things they way they were done way back in ancient history. I posted about that in 2010 – see Batch renaming of photo files. Nowadays I do it a bit differently.

I have set up a “batch file” that resides on my desktop. The photo files are imported into a folder. That folder is then dragged and dropped on the batch file icon. That’s all. The job is done.


Occasionally I get “heavy-fingered” and hold down the shutter button a tad too long and get more than one photo. The file name will be the same for date and time to the seconds and only differ in the fractional second part – beyond what I want to retain as the new file name. Nothing bad happens! The second file will just not be renamed. With my pattern the original name started with “20” which sorts before the new names starting with “LK” so the file that was not renamed will be at the top in the folder.

You can see this illustrated in the above screen captures. See the two photos just under the top of the yellow arc that shows the drag-and-drop operation. Sometimes I rename such a file manually, often it is just a duplicate image that can be tossed.

Now the gory details

Windows still offers “command line commands”. If you open the “cmd” command prompt window you can direct Windows with typed commands. Those commands can also be typed as a script in a plain text file. When such a text file is saved with a “bat” extension instead of the normal “txt”, then Windows knows that it contains commands. My renaming script file contains the following:

REM rename iPhone photo files - naming pattern: 20230327_165036028_iOS.heic
cd %1
ren 20*.* LK??????-??????.*

The first line that starts with REM is a “remark”. It doesn’t do anything. It is just there as an explanation to myself.

The second line stars with “cd”. That is the command to “change directory”. In the “olden days” folders were called directories. The other part, “%1”, is the interesting one. It means “the first parameter in the command call”. Since the script was called by dragging the folder to the desktop shortcut icon, this means “do the commands in the folder that was dragged in”.

The third line starts with “ren”. That means “rename all the specified files in this folder in the following pattern”. The next item specifies the file names that are to be replaced. The “20*.*” says basically, “the files that start with “20” with anything after that up to the dot, and anything after the dot”. The final item specifies the new name. It starts with “LK”, those characters replace the first two characters. The “?” question marks say “keep whatever character is in this position in the original name”. The “*” asterisk says “keep whatever starts in this position, however long it is”.

If this intrigues you and you want to learn more, search the internet for “command line commands” and “Windows batch files”. I will also gladly answer your questions over at Ask Ludwig.

.:. © 2023 Ludwig Keck

About Ludwig

Lending a helping hand where I can. . . My motto: If it is worth doing, it is worth doing well.
This entry was posted in Computer - general, Uncategorized and tagged , , . Bookmark the permalink.

5 Responses to Renaming iPhone photo files

  1. Robin King says:

    Very interesting! Not using Windows so I can’t try it but it sounds really useful! 👏🤗👏

  2. lifelessons says:

    Phew.. my head is swirling. My photos app on my Mac gives an image number to the photo file when it arrives from my camera. I sometimes add a description before this but rarely do. I used to be able to look them up in the media file in WP when I wanted to use them in a blog again but it seems not to hve saved the old ones, I do a google search or search in my blog file by tag and can usually find them this way… or I start searching through the 142,525 photos in my Mac photo file. Urgh.

  3. Auto news360 says:

    Quite fascinating! I can’t try it because I don’t use Windows, but it looks really helpful! 👏🤗👏

  4. Adobe Bridge (free) also has a batch rename function. In my ancient version (2010) it’s under Tools. I’ve used this for organizing photos, etc forever.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s