Shortcuts quick action help - when renaming to creation date, add numerical suffix to files with same date

Hello,


I'm trying to create a quick action in Shortcuts that renames the selected files by their creation date. This is for organising holiday photos taken on multiple devices (iPhone, SLR camera) that use different file naming systems. However, some photos appear to have been taken within the same second, so the shortcut errors.


How can I make it so the shortcut adds a numerical suffix onto the end of the files after they have been renamed so that they both can be renamed to their creation date? I've also tried having it add milliseconds onto the creation date but that doesn't seem to be an option. Basically, similar to the 'Keep Both' option you have when renaming in finder but add that into the shortcut.


Thanks for any help!


This is the shortcut as it currently stands:

Current date created format is: Custom:

yyyy-MM-dd_HH-mm-ss


Error message:

Mac mini, macOS 26.6

Posted on Sep 13, 2026 1:43 AM

Reply
13 replies

Sep 13, 2026 6:57 AM in response to AglaVerin

The Date Created is not the EXIF->DateTimeOriginal date, but rather the Finder creation date. If you really want the date that the picture was taken, not when it was written to macOS, then you will want the EXIF Metadata.


I would set that Quick Action Receive to Images from Quick Actions. Here is how you get the EXIF DateTimeOriginal back as yyyy:MM:dd hh:mm:ss. It does not store milliseconds:



Note that I have used dot-notation to directly get the DateTimeOriginal dictionary member information. I happen to prefer the date/time formatted in a modified ISO-8601 format when used for filenames:

yyyy-MM-ddThh_mm_ss


to keep the Finder from converting its reserved colons to '/' replacement characters. That is ugly in a Finder filename and will bork accessing the file on the command-line too where '/' is also a reserved path separator.


In addition to reformatting the date/time string above, the Get File Extension action returns an uppercase extension. I solve both the date/time reformatting and forcing the extension to lower case in a brief Run Shell Script where the only input is the DTO string as "${@}" as a command-line argument:



Now I can simply rename the repeat item to DTO_Formatted in the original image source location:






Sep 13, 2026 5:14 PM in response to AglaVerin

The file you selected does not have a Date Taken value. For instance, my Mac screenshots do not have a Date Taken value (My photos do). If I run your shortcut on a screenshot, it fails at the same place as yours.


You have to decide what action to take if Date Taken is absent. Here is an example where the shortcut reverts to the Creation Date if Date Taken is missing : Rename Image Files with Date Taken.

Sep 14, 2026 3:47 AM in response to AglaVerin

Images produced by a camera or cell phone should have an EXIF dictionary that contains the DateTimeOriginal data. Computer generated images won't have this field and the DTO variable would not get populated, causing the shell script to generate incorrect or no output.


The shell script expects the content in the DTO variable to be in the numerical format yyyy:MM:dd hh:mm:ss. Your Format action result is not being used, and if it were, the shell script and the DTO_Formatted variable would be unnecessary as you could premise the rename on the Format result.

Sep 13, 2026 8:38 AM in response to VikingOSX

Thank you very much, I didn't realise the difference; that would make more sense as to why some files were being seen as exactly the same.


However, I've tried integrating the first part but it is returning the following error message:


In ' ', no value was found for dictionary key '{Exif)'.


Am I copying it wrong or do I need to also include the shell script as well for it to work at all?; I interpreted it as the second part is optional if I want the file extension lower case and the date reformatting?


Thank you


Sep 13, 2026 9:01 AM in response to AglaVerin

AglaVerin wrote:
Thank you very much, I didn't realise the difference; that would make more sense as to why some files were being seen as exactly the same.
However, I've tried integrating the first part but it is returning the following error message:
In ' ', no value was found for dictionary key '{Exif)'.

Your typo. {Exif}.DateTimeOriginal


It wants a matching curly brace.

Am I copying it wrong or do I need to also include the shell script as well for it to work at all?; I interpreted it as the second part is optional if I want the file extension lower case and the date reformatting?

See my new shell script just posted this (9/13) morning. The Finder uses the colon character as a reserved path separator and when encountered in a file or folder name, will display the ':' as '/'. That is ugly to read. In the UNIX filesystem from the Terminal, the colons will remain in the filename since they are not path separators in that Shell.

Thank you
https://discussions.apple.com/content/attachment/ce1238bc-e559-482c-8c63-d3a0798d86aa


As I mentioned in my 11:41 post today, the Rename action only addresses the basename of the image file, so there is no need to deal with the extension at all. Again, see the new Do Shell Script for that revision.


Or, you can completely skip my Do Shell Script formatting solution and use 6x6's suggestion for Date Taken and then use the Format action afterward. You just don't want colons in your filename.

Sep 14, 2026 1:02 AM in response to 6x6

Thank you, I'll include that for items with no Date Taken. It seems there are some photos with same Date Taken and Date Created, so I think what I'd like is for it to use Date Taken as suggested, but if there is already another file with the Date Taken name, then it adds a number on as a suffix (e.g. _1, _2, etc.). Do you know how to get it to do that as it seems like all the If options only relate to things happening within the shortcut workflow not destination folder?

Sep 14, 2026 5:00 PM in response to AglaVerin

AglaVerin wrote:
Do you know how to get it to do that as it seems like all the If options only relate to things happening within the shortcut workflow not destination folder?

I've been working on a solution. I got the shortcut done but I need to stress-test it on a few examples. I'll report back when I'm done.

Shortcuts quick action help - when renaming to creation date, add numerical suffix to files with same date

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.