Stuck on Rename/Move

Hi there! I've tried to be brief but I still want to say thank you. Here's the info:

I'm on Mojave 10.14.1

What I'm trying to do:

  • Copy the name of a folder with photos in it
  • Open that folder and compress all the photos into an Archive
  • Rename the Archive to the folder name I copied and move it to another folder

The problem
I keep getting the error message "File action failed because destination already exists"

I'm hoping this is super easy to fix since I know I'm probably wasting people's time with such a basic problem but I haven't made any headway despite reading the wiki over and over and searching the forums over and over again.

Do Something with JPG files copy.kmmacros (3.9 KB)
48%20AM

Hey @dduncombe,

A few things pop out.

You're not using VarName anywhere.

Opening a folder (Cmd-O) and typing Cmd-A are better done manually, because it's two keystrokes – and you don't have to mess with pauses.

If you need the macro to do this then you need to wait until the folder opens before selecting-all.

You also need to wait until Compress finishes before trying to move the Archive file.

You need to make sure an “Archive.zip” file doesn't already exist at your destination.

Rule-of-the-thumb – never use local variables while testing, because they make your macro much more difficult to debug.

Your %Variable%filePath% token doesn't match your variable LocalFileName.


I think your compression task is probably better done with the command line utility ditto, because you can actually manage control-flow that way.

I'll come back to this a bit later when I have a bit more time.

-Chris

Hi Chris!

Thank you so much for taking the time and the advice. I got it to work using the method I've attached to this post but I'm going to look at your suggestions since I don't really understand how I got it working.

Opening a folder (Cmd-O) and typing Cmd-A are better done manually, because it's two keystrokes – and you don't have to mess with pauses.

I would never have thought that, interesting. I used those kind of commands before but felt like they were bad workarounds so that's great to know.

You also need to wait until Compress finishes before trying to move the Archive file.

Adding a pause for the Archive Utility is one of the things that I think got it to work.

You need to make sure an “Archive.zip” file doesn't already exist at your destination.

This did get in the way when I was testing because I'd forget that I had run a test and then it would fail because the previous test had created it.

Rule-of-the-thumb – never use local variables while testing , because they make your macro much more difficult to debug.

I'm not sure what you mean by local variables or what the alternative is (I have a lot to learn) but I'll try to figure it out when I go back to edit it.

I think your compression task is probably better done with the command line utility ditto , because you can actually manage control-flow that way.

I saw that in another post but couldn't get my head around it. I will try again when I'm not under pressure to make it work.

Thanks again for the help, I really appreciate it.

Hey @dduncombe,

Any variable that's prefixed with a variant “local”

See the wiki Variables section.

Local variables are transient and don't show up in Keyboard Maestro's variables panel in the prefs, so they cannot be seen for debugging purposes – unless you deliberately show them in a text window or some other viewing medium.

Since you're cleaning your zip file in your macro I'm guessing you need a platform agnostic archive.

That's easy to achieve using the zip utility in the shell. Appended is an example.

BE SURE your images folder is OPEN and FRONTMOST in the Finder before running the macro.

You do NOT need to select the image files.

-Chris


Zip All Files of Frontmost Finder Window to a Given Location.kmmacros (8.6 KB)

Oh wow, thank you so much! I really appreciate you putting together that macro for me and all your help; you've already made things a lot easier.

1 Like