How to duplicate and rename the duplicated file

Using Keyboard Maestro 8.2.4 - macOS 10.13.6

I wish to duplicate a file and then rename the duplicated file.

The situation is as follows:

  1. I create a number of PDFs, which are all named along the following same pattern:
        “2018_154 - client name - name of document - notarised covering certificate.pdf”

  2. “2018_154”, “client name” and “name of document” all change for matter to matter.

  3. “notarised covering certificate” remains constant and is always at the end of the file name.

  4. I wish to
    (a). duplicate the file “2018_154 - client name - name of document - notarised covering certificate.pdf”; and
    (b). rename the duplicated file to “2018_154 - client name - name of document - complete notarised document.pdf”

Duplication causes the duplicated file (before renaming) to be named to “2018_154 - client name - name of document - notarised covering certificate copy.pdf”

[After duplication and renaming, I will add other PDFs to the duplicated/renamed file.]

Although I have made a macro which achieves the above, it does involve several sets of steps.

I would like to know if there is a simpler way of doing so.

The macro I made:

Search and Replace.kmactions (707 B)

image

I'm afraid you only included a single Search and Replace action in your upload, so we can't tell what your full macro looked like, but this macro, which will work on any number of files selected in the Finder, uses only two steps, not including the enclosing For Each action:

Copy and Rename Selected Files.kmmacros (2.3 KB)
image

Essentially, there's no need to duplicate and then rename the file; you can rename the file when you duplicate (copy) it by searching and replacing the original file name/path to a new variable, as you seem to have done in your original macro, and using it in the copy action.

1 Like

gglick,

Thank you.

A separate message from ccstone let me know that I had not posted my macro but just an action from the macro. What I was trying to do was not coming through, but your macro provides the solution for what I need do (and is much simpler) and taught me more about what is possible to do with variables.

Victor

2 Likes