I'm trying to create a macro that copies a particular folder (A) and pastes it to within another particular folder (B), on a regular basis. A prior version of A already exists within B, which I thought would produce the standard "already exists" dialog box. Instead, the macro simply fails": "File action failed because destination already exists."
Or perhaps I'm misunderstanding that error message. Does it mean that it fails instead of producing the "already exists" dialog, or because the paths I use in the Copy File action don't make sense. To be clear, I want to copy one folder, including its contents, and paste it to within a different folder (where another version of the copied folder already resides). Those are the two paths I've entered in the Copy File action.
The long pathnames make this hard to follow, but suffice to mention that they are both folders.
Can the Trash File action delete entire contents of folders? My destination folder is, I believe, a protected one and it won't do to delete it and then create a new one of the same name.
My destination folder is, I believe, a protected one and it won't do to delete
Meant to say:
1.- In MacOS Finder, duplicate the folder you want to send to Trash, this duplicate will be your testing playground.
2.- In Keyboard Maestro, create a new macro with just one action: Trash folder: for the path, select the duplicated folder you just created.
Thank you for your help, but I'm afraid I'm getting more confused rather than more clear. For one thing, I'm not sure what the advantage of using an AppleScript is over doing something within KM natively.
Next, I'm not sure how to adapt the script in the "Trash vs. Delete" link to my purpose. I tried changing the folder name in it to that of my target folder, but the macro doesn't do anything at all.
And, I'm not sure what you're recommending I do: copy the target folder in order to delete it? Are you thinking to delete the target folder and then create a new one of the same -- rather than just clear it of its contents -- before pasting the content I want to put there?
Sorry, but I don't see where @hello even mentions AppleScript.
IAC, if the desired automation can be done acceptably using KM non-script Actions, then I generally recommend doing so.
OTOH, there are some automations that KM cannot do without a script, or a script makes it much more efficient.
I think @hello is trying to suggest that you INSERT into your Macro the KM Action Trash Action so that if the folder you want to copy already exists in your target folder, it will first be moved to the macOS Trash:
After taking a closer look at this, I realized it is more complicated than I first thought.
So here's an example Macro to help get you started.
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.
First, make sure you have followed instructions in the Macro Setup below.
See the below "How to Use" Comment Action
This macro 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.
MACRO SETUP
Carefully review the Release Notes and the Macro Actions
Make sure you understand what the Macro will do.
You are responsible for running the Macro, not me. ??
. Make These Changes to this Macro
Assign a Trigger to this Macro .
Move this macro to a Macro Group that is only Active when you need this Macro.
ENABLE this Macro, and the Macro Group it is in.
For more info, see KM Wiki article on Macro Activation
.
REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
(all shown in the magenta color)
Set DESTINATION Folder
CHANGE to your Destination Folder
Default is iCloud Drive
REQUIRES:
KM 9.0+ (may work in KM 8.2+ in some cases)
macOS 10.12.6 (Sierra)+
TAGS: @Example@Copy@Folder@iCloud@Trash
==USE AT YOUR OWN RISK==
While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
If you have any doubts or questions:
Ask first
Turn on the KM Macro Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
The first run will be a copy but subsequent runs will efficiently just copy changes (very quickly). The target (the last folder named) will mirror the source.
You would be "done with it" only if you wish to hard code both the path to the source folder and path to the destination folder.
Obviously, if you wanted to allow the user to choose the source and/or destination folder, it would require more KM Actions, and a significant change to your shell script.
My above Macro provides these choices.
I don't recommend it, but if the user wished to hard code the paths, it could be done in just two KM Actions:
Finally, before the user uses a shell script command like rsync, they should make sure they fully understand what it does by reviewing the appropriate documentation and other examples (like at stackoverflow.com). I would personally do this since I have no prior use or knowledge of the rsync command.