March 19, 2023, 3:13pm
Does anyone know if it's possible to create a macro that renames files in a folder based on a list in clipboard?
The files are numbered (or at least they all contain a number in a sequence) and each should be renamed from
Any suggestions? Im new to KM and slowly trying to build macros. So I just want to know if I'm heading down a dead end or not.
Sure you can, but personally I think this is a very bad idea – there are too many things that can go wrong.
I think it's better to actually map your replacements directly, so there can be no mistakes with sorting or interruption of the Clipboard – etcetera.
Personally I'd use
BBEdit, because it's very scriptable.
I recommend BBEdit because…
Although BBEdit is a commercial product, the trial version reverts to a
still very powerful and free (BBEdit-Lite) version after 30 days. It is very Mac-like.
It has excellent support for RegEx.
It is very AppleScriptable.
It has a two versatile command line tools.
It has been in continuous development for over 25 years.
A decent alternative is
CotEditor, but it's not nearly as powerful as even the free version of BBEdit.
Another alternative would be Apple Numbers.
So your document would have a tab-delimited table of name-value – rename-value:
With enough tab separation to create a neatly ordered table.
You then use an
Execute an AppleScript action to get the values into Keyboard Maestro and process from there.
Let me know which way you want to go, and I'll provide some more guidance.
March 20, 2023, 4:56am
Interestingly I just looked at BBedit last week.
I use VScode and Sublime and they seem fine for almost everything I'm doing so far.
Happy to go with either method but intrigued by the first one, which I guess is some kind of shell script?
I like VSC and have mixed feelings about Sublime – unfortunately neither of them is AppleScriptable.
The appended macro makes use of a rename map table in a BBEdit document named “File Rename Map.txt”.
The BBEdit document MUST be named this way, although the user can change this if desired.
The Target-Directory is the FRONT FINDER WINDOW.
not taken the time to build in error-checking for a missing rename table window and various other things. If I was building this macro for myself I'd have done all the heavy lifting in AppleScript.
(7.5 KB) Download: Rename Files from Text Table in BBEdit v1.00.kmmacros
Create your rename table.
Make sure it is named “File Rename Map.txt”.
Make sure the table is open in BBEdit.
Make sure the target directory window is open in the Finder and FRONTMOST.
Run the macro.
always disabled when imported into the Keyboard Maestro Editor.
must ensure the macro is enabled. The user
must also ensure the macro's parent macro-group is enabled.
Keyboard Maestro v10.2