Is there a way to change only the time of a file's creation/modification date/time?
The date and time are not two distinct attributes fields or values – just one quantity of seconds since an epoch date (the opening moment of 1970), which the stringifications present in terms of a date and time combination, for readability.
What you need to do is just calculate the new moment that you require, and then restamp the file.
See, for example:
[Unix time - Wikipedia](https://en.wikipedia.org/wiki/Unix_time)
for documentation of the touch command
and this thread for previous discussion:
As @ComplexPoint has stated, files/folders only have date/time properties as one unit.
Also, while we can easily get the file time using native KM Actions, I don't see any way to set the time without using a script.
So, this is a bit complicated because we must first separate date only and time, and then recombine with the new time. So, I have used a couple of AppleScripts to do this.
Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.
Please let us know if it meets your needs.
You are prompted with the current Created Date/Time, and then you can change the time (and date) as desired.
MACRO: Set TIME to User Provided Value for Finder Selection [Example]
-~~~ VER: 1.0 2020-11-24 ~~~
Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
DOWNLOAD Macro File:
Set TIME to User Provided Value for Finder Selection [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
- Set the Creation and/or Modification Date of Item in Finder Selection
HOW TO USE:
- Select the Item in the Finder
- Run this macro
TAGS: @Dates, @Finder, @Files, @ASObjC, @ShaneStanley
ACTION COLOR CODES
• To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
• GREEN -- Key Comments designed to highlight main sections of macro
• MAGENTA -- Actions designed to be customized by user
• YELLOW -- Primary Actions (usually the main purpose of the macro)
• ORANGE -- Actions that permanently destroy Varibles or Clipboards
- Keyboard Maestro Ver 9+
- macOS Sierra+
This works exactly as I need it to.
Many many thanks!