[SOLVED] File name editing from clipboard (and drag&drop)

I've found this tool some days ago and I wanted to test some tasks before buying.

One of them would be quite simple, but with my lack of knowledge, I am stuck.

The task:

  • In Finder on a folder: Pressing to edit the folder name.
  • Marking some text and copying it to the clipboard (with +).
  • KM should now start its job: While still in the Edit-mode on the folder: Go to the end of the folder name.
  • Paste " [clipboard contend]". (without the "" and "clipboard contend" is of course the actual clipboard contend)

A folder named text1234
should afterwards be named: 1234 [text]

Very simpel.
Trigger in KM is: "The system clipboard changes".
But there is no action. Just "Rename a file" and that's not working in this case.
Is it even possible?

And another question: For another use case I would need to drag and drop all files from the currently selected folder into an application. (No the application does not support "paste")
Is such a thing possible with KM?

edit: drag&drop is possible as far as I read here in the forum. But I don't know if "all files in the current directory" are drag&drop-able.

Thank you for even reading this. :slight_smile:

One thing to be aware of is that using the Trigger "The system clipboard changes" to fire the Macro means it will run every single time anything is copied to the Clipboard which is probably not a good thing.

So, you want to select some text in the folder's name, cut that text and move it to the end of the folder name in square brackets?

There are many ways to do this. One way is to use Keyboard Maestro to replicate what you would do manually. So, a Macro could be made to do these things:
Cut the selected text to the clipboard
Use ⌘→ to move the cursor to the end of the folder name
Paste in " [the clipboard text]"

Cut Selection and Put at End of Folder Name.kmmacros (3.3 KB)

Click to Show Image of Macro

Screen Recording 2024-03-04 at 20.53.05-Animated GIF

I'm not exactly sure what you mean by this. When you say "drag into an application" do you mean "drag into an open document in an application" or "drag to the application icon"? Do you simply want to open the files in a particular application?

1 Like

Thank you very much for the quick reply.

I know. I would activate the trigger only to do exactly this one thin on several folders. Afterwards it will be deactivated again.

This is what I mean by drag&drop into an application:


The application is Audiobook Builder. With the help of ChatGPT (my C knowledge is rusty and old and was never used after learning it) I managed to write a python program which automates everything to run through the steps in Audiobook Builder - except for the drag&drop part. The program is waiting for me to drag and drop. The I have to press and the program continues.

It's not entirely clear to me what you want to do since you changed from renaming files to dragging files, but as far as renaming files, there are ways you can rename files in Keyboard Maestro, including batch renaming, but also note that you can batch rename files natively in the Finder.

In the Finder, if you select a bunch of files and then Control click on them and choose Rename, there is a batch rename functionality built right in, and if that meets your needs it might be a good solution.

Alternatively, there are batch rename macros on the forum, for example:

As well as various batch renaming tools.

And you can use the techniques described here:

to work the the finder selection to do whatever you want.

As fas as your first question, a macro that does Type a Keystroke Command-Right Arrow, followed by Insert Text by Typing action “ [%SystemClipboard%]”, and then type a return will rename with the clipboard.

Those are just two different tasks I wanted to do with Keyboard Maestro.

I know. The folders I want to rename are very different. Some have to be renamed, some not, some have two words to cut out, some one or three, some have a "-" afterwards which could identify the position of the cut, some don't.

So I tried the method above and managed to build an endless loop :crazy_face: . (I've done too much at once I guess.)

Now it is working just fine (the renaming part). I wanted to make it myself and not just download the provided macro. :upside_down_face:

1 Like

Instead of drag'n'drop, which can be a bit pernickety, use the "Add Files" menu item from the "Audiobook" menu -- you can use KM to trigger the menu item then set and choose the folder of files to import and there's plenty of examples of how to do this on the Forum.

To make life easier -- a quick test shows that you can import a folder and all the music files in that folder will be included. So to do what you are doing in the video above you would import the "ORIGINAL" folder to add those 20 mp3 files to your project.

I can press the "Add files" button via python, but then... ok never thought of this:
I can press shift+command+g and paste the actual folder, then select and done.

I will try this first. Thanks for pushing me in this direction!

I have done everything (regarding drag&drop) in Python now.
Anyway I will buy Meyboard Maestro. I love such a tool. ::

1 Like

Ahh, ok, probably better to have one topic per question (unless they are tightly related), it helps keep everything straight and avoid confusion.

Yes, Command-Shift-G is key to controlling the Open/Save dialog box.