Move To Folder REname file

hey all,

I am working with files where the original user did not assign unique names. the macro works as expected for the first file. but i cancels for any file with the same name and for the life of me i cannot logic out how to tell KM to move the file anyways but assign a numeric suffix. i have tried split path, switch case, using a calculation.

i am stumped. here is where i stopped and consulted the forum.

thanks much
-b

Move To Folder Macro (v10.2)

Move To Folder.kmmacros (4.4 KB)

Here is one way you can do it with the Keyboard Maestro Action Create Unique File

If the file name already exists in the destination folder, this Macro creates a unique file. It saves this path and filename to a Variable. It then deletes the unique file it just created and uses the Variable it saved to move and rename the file you are trying to move. I know, it feels convoluted but it works...

(To use this Example for your files, change the Source Folder that triggers the Macro to your actual Source Folder and the Destination Folder in the Magenta Action to your Destination Folder. But first test it on some dummy files/folders to make sure it works as you want. Also, be aware that when Keyboard Maestro moves files there is no Undo...)

EXAMPLE Move File to Folder and Create Unique if Name Already Exists.kmmacros (18.6 KB)

Click to Show Image of Macro

1 Like

Oh Man! this is great thank you so much.

I Spoke Too Soon....

this macro still cancels when it sees the first file in the destination folder.

what am i doing wrong?
Move To Folder.kmmacros (4.6 KB)

also, apparently i don't know how to share a macro directly from the keyboard maestro editor without creating a new topic

In the Macro you uploaded I noticed some errors which I've fixed and it now should work. Here is your Macro edited as version 2.

Move To Folder V2.00.kmmacros (4.2 KB)

Click to Show Image of Macro

  1. You had a Variable called Local_SourceFile which you spelled as Local_SourceFle lower down in the Macro. I find that using Copy and Paste with Variable names is a good way to avoid typing mistakes.

  2. You had changed the Move Action in the first part of the Try Catch. You had unchecked "Failure Aborts Macro".

Counterintuitively this needs to be left on the default setting. The logic being that the failure of the Action to copy the file, sends an Abort Macro command and triggers the second half of the Try Catch...

By unchecking "Failure Aborts Macro" you are telling the Macro to not fail on that Action but just to move on. And as there are no further Actions beyond the Try Catch the Macro does nothing. But because you had left "Notify on Failure" checked you were still getting the Notification.

So, it should be set up like this:

  1. I don't think your second trigger is going to work with this Macro (if a Volume is mounted) so, it is not worth having. The reason it won't work is that you are using %TriggerValue% to get the file's path/name and a trigger that fires when a Volume is mounted is not going to give you a file path/name.