Rename a File

Hello,

I hope you can help me, thanks for opening this Topic.

I am running KM 10.0.2 and MacOS BigSur 11.6

Background

In my job I receive work from numerous sources. I have a file structure that, so far as is relevant, is:

Name of Referrer> Name of client 1> name of client 2> date and type of work, so could be:

Bloggs Ltd > Smith > Jones > 2022 1 30 Written work

The date and type of work stage is important and changes with each new piece of work: sometimes the work will be at short notice, sometimes I will receive the instruction to do the work weeks or months before it is due.

Macro

I have a KM Macro which, when triggered by a keyboard hotkey,:

    1. “Prompts for User Input” and gives me the following fields and variables:
    • a. Referrer name,
    • b. Client 1 name,
    • c. client 2 name and
    • d. date and type of work; then
    1. Creates the folder structure in the correct location and in the above hierarchy; then
    1. Copies generic documents I use for the particular bit of work into the “Date and type of work” folder, and finally
    1. Opens the folder structure in finder inside the “Date and type of work” folder.

So after the macro has run I am in the folder and have, say, 4 standard documents in front of me. These are labelled, for example: Client Contract, Record of Meeting, In Meeting Notes and Standard Questions.

So-far-so-good.

Problem

What I want is for KM to rename the standard documents and I cannot get this to happen. I cannot get KM to rename the files I have just moved into the “Date and Type of Work” Folder in step 3 above.

I want them to change name to “%Variable%Date and Type of Work% Client Contract.doc” so in the example above would be “2022 1 30 Written Work Client Contract.doc”, and 2022 1 30 Written Work Record of Meeting.doc” etc

The “move or rename a file” action does not help as it needs me to specify a folder in advance in which to seek the file to rename. Here before the macro has run there is no folder I can specify. And even if I could, I cannot find a “rename” command.

I have looked at using a Hazel rule, but hazel will only amend the date to a set date e.g. the date created, date opened etc, and not the variable date I want the documents to be recorded as.

Does anyone have any tips on how to get this final step resolved and the files renamed?

The “Rename” command is kind of hidden in the Move A File Action. You use “Move” on the selected File or Folder but you leave out the file path. Just have the new name (which can include a Variable or Token like a date) and remember to include the extension if it is a file rather than a folder you are renaming. That will rename the selected file or folder without moving it. This has confused me a lot in the past.

https://wiki.keyboardmaestro.com/action/File_Actions

1 Like

@ Zabobon

Thank you SO much for taking the time to respond...you advice has solved my problem.

Thank you again!

1 Like