I haven’t used Keyboard Maestro for a while. Basically I just want to copy a file from my iMac to a Mac Mini that has been triggered by a hot key. The file exists in the new location so will I have to delete that first and then copy it over?
To copy the file, use the "Copy a File" action.
You'll need to delete the destination file first. There's a couple of ways to do this.
or, and I would probably use this:
As you can hopefully see, you can just use the "Delete File" action, and turn off the option that notifies you of failure.
Put together, this is what it would look like:
Will this work for a folder. What I am trying to do is copy an Xcode Project to my Mac Mini.
To check for a folder existing, use the IF action, with a “Path” option that checks if a folder exists.
To delete a folder and all its subfolders, use the “Delete file” action, and change it to “Delete Dir”. BE VERY CAREFUL with this action - you could delete almost everything on your disk using this action.
To copy a folder, use the “Move or Rename a file” action and change it to “Copy”. It works with folders as well as files - just specify the folder.
If I’m not misreading the macro it should be sufficient here to use the ‘Trash File’ action. This way, if something went wrong, you’ll find the accidentally removed files in the Trash Can. I know, you can recover deleted files, too, but it’s more complicated and it won’t always succeed. (Especially on SSDs and/or if you wait too long.)
The Trash File action works with folders, too. Once the macro has proven that it is targeting the correct file/folder, you can always change the action from Trash to Delete, if really necessary.
Great answer. I didn’t realize that Trash worked with folders also. And yes, MUCH safer.