Appending a timestamp to a file name

Greetings,

Here’s what I’d like to do but can’t figure out, perhaps because it’s impossible.

I have an important file, that change all the time and I’d like to periodically copy it to an “archive” folder then change the name to a base (eg LP) with a time stamp.

Something like LP YYMMDD HHMM.xyz

I seem to be able to copy the file to the correct directory but can’t change it’s name (although that’s probably solvable) and cannot figure out how to append the date and time.

Any help would be appreciated.

Happy New Year!

I think you're probably looking for the ICUDateTime token and the Rename a File action. Something like this:

2 Likes

@wwalsh8655

@hemicyon set you on the right direction if you want to build your own.

I feel I am “killing a fly with a hammer” with the remainder of my response but here I go anyway.

Peter Lewis posted a collection of his macros in Best Examples of Keyboard Maestro Macros - #6 by peternlewis

One of these is the “Rename Files to Creation Date” macro. With some minor modifications to his macro you will have a robust tool to address your use case.

K-Thx-Bye!

I expect that the answers here will have been correct in assuming that “the date and time” refers to the date and time at which you are renaming the file. I shall just mention however that in case you wanted to use the file creation date or file modification date, the easiest way to access these is by using the Get file attribute action.

Making the assumption that you trying to do this manually. then I have a macro that just pastes the time stamp in

Insert Text “%ICUDateTime%yyyymmdd HHmm%” by Typing

this has no special characters and uses the insert text by typing action.