Copy folder between devices, and add date/time stamp

I would like to write a macro which would:
1- copy a folder from one device to another
2- on the destination device, a date/time stamp is added to the folder name
As a result, on the destination device, I would see a series of folders with different date/time stamps
It could be considered a kind of folder backup with versioning.
Thanks very much for your time and help

I don’t know if you want to copy folders selected in the Finder, or just otherwise specified folders(?)

A very basic macro example to copy a specified folder to another volume, with timestamp:

_Tmp.kmmacros (1.7 KB)

To customize the time stamp see here.


Fantastic ! Thank you so much for your time and help !!

Your macro is fantastic. Works perfectly.
I notice that the 'modified' date - time' of the destination folder is the same as that of the copied folder.
Why would that be? Is it possible to configure the macro so that it is the date/time the folder was backed up?
Thanks again very much

Below is the date modified of the destination folder which was copied (create) at 17:50

I know that theoretically, I could use the date created, but El Capitan OS is a bit buggy as far as date created is concerned.

I think the Modified Time of a folder gets updated when you add/remove a file.

You could use the Set File Attribute action to set the time of the folder:


thank you. I will try the folder modification you suggest. I have 2 problems:
1- changing date time stamp.
I tried to modify the data / time stamp and messed it all up.
Instead of
I tried
and also
%ICUDateTime%-yyyy-MM-dd at HH-mm%
The objective is to end up with a name like 2016-10-16 at 10:50 , just to make it easier to read.
2- I would like some kind of notice to flash on the screen (something like the usual notifications), just to make sure that the macro ran correctly. What would you suggest.
thanks again very much

For the inclusion of decorative letters you have to use '', as in my example string from above. Other characters, like -:. or spaces don’t need to be escaped.

So, to get 2016-10-16 at 10:50 you can write

%ICUDateTime%yyyy-MM-dd 'at' HH:mm%

or shorter

%ICUDateTime%y-MM-dd 'at' HH:mm%

However, you can’t use : in filenames. The : will be converted to / in the Finder. If you don’t like that, use for example a dot . instead of the :.

The earlier post contained a link to the date format reference page.

I would like some kind of notice to flash on the screen (something like the usual notifications), just to make sure that the macro ran correctly. What would you suggest.

You have already named it, so why not using a Notification action?

You can also use variables in the notification text. Of course, you have to set the variables before. Here is a complete working example:

_Copy Folder [Example].kmmacros (3.5 KB)

Set the correct paths in the green actions.

One thing to keep in mind:

If you run the macro twice within the same minute (i.e. the time stamp is still the same) the folder will be copied inside of the previously copied folder.

If this is a problem, add seconds (ss) to the time stamp, or even fractional seconds (S).

just to make sure that the macro ran correctly.

Always click the Gear icon of essential actions:

If the action is critical (like the copy action in the example) make sure Notify on Failure is checked.

Depending on the structure of the macro, you might also want to check Failure Aborts Macro. In the example I’ve checked it because we don’t want to see the success notification if the copy action has failed.

1 Like

a fantastic reply. Both obviously useful and very educational. Thank you so much !!

I looked at your date time sytax reference.
in view of your caution about the macro acting differently if run within a minute, I wanted to add seconds, and changed the stamp to:
%ICUDateTime%y-MM-dd ‘at’ ‘and’ ss ‘seconds’%
it should end in … ‘and xy seconds’ the xy being 00 to 60, but obviously, like everything I do, it does not work.
thanks !

Your string (copy-pasted from your post) works flawlessly here.

Maybe you have forgotten a single quote or a % sign.

1 Like

I checked it digit by digit, ran it 30 times, tried all kinds of changes, and I get as folder name:
accounting 2015 2016-10-18 at 16.01 ‘PM
I think that it has something to do with the date time configuration on my computer.
Life is too short to waste time on such a minor issue.
thanks again very very much

Shouldn’t affect it. Just upload[1] your macro and I’ll see if it works here.

[1] Select macro in KM Editor, File > Export Macros…, drag the exported .kmmacros file into the edit window of a new post.

1 Like

thanks very much. Don't waste your time if it is not obvious.

copy folder troubleshooting duplicate.kmmacros (3.4 KB)

It is obvious :wink:

You have the wrong quote characters in your string. You must use straight single quotes (''), you have used normal (aka typographic) single quotes (‘’):

Your string:

%ICUDateTime%y-MM-dd 'at' ‘and’ ss ‘seconds’%

Correct string:

%ICUDateTime%y-MM-dd 'at' 'and' ss 'seconds'%
1 Like


When editing in KM Editor you should disable Smart Quotes. (Edit > Substitutions > uncheck Smart Quotes)


Thanks for this. What about "Smart Copy/Paste"?

1 Like

I will have to look into it. thank you

thanks very much Tom !

it was unchecked, but Smart/Copy Paste was checked

I would disable everything ‘smart’ :wink:

(I think Smart Copy/Paste can add spaces where you you didn’t want them.)