Rename files with first line Macro (v11.0.2)

Rename files with first line Macro (v11.0.2)

Hi- big picture I'm trying to make sure my markdown note 'title' and filename are consistent in order to transfer notes from NotePlan to Obsidian.
I'm having some issues with this macro that is slightly different than others I've seen. I'm trying to batch rename files in finder to match the first markdown 'title' (after '# ' since these were originally markdown files) within the text file. I've already converted my .md files to .txt files temporarily so the 'read file' action works appropriately and it seems I can get this to work on a single file basis but I'm having trouble figuring out how to loop it through either a group of selected files in Finder or all files within a folder. If duplicate file names are anticipated to be a problem, I'd rather skip the file rename for that file than move it elsewhere as it doesn't need to be changed if the file name and title are the same.
Any help is much appreciated

Rename files with first line.kmmacros (7.3 KB)

Of note, I was alternating between the action 'prompt for file' and 'Get Unquoted POSIX Path of First Selected Finder Item' to trouble shoot, I'm not looking to use both

I'm not sure if this is exactly what you want, but it worked on my test files. However, the caveat is that I know about zip about Markdown, so my macro is set up to simply extract everything after the "#" on the first line where the # is found.

It's also set to work with a selection of files in Finder, not a folder, but that could be changed. Please test with a small subset copy of your real files!

Download Macro(s): __File Renamer.kmmacros (6.1 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 13.6.5
  • Keyboard Maestro v11.0.2

-rob.

Hello Olivia (@Olivia_Rice):wave:

Welcome to the forum.

We all try to help based on our time and knowledge to give the most precise answer possible based on what we think is asked by the person that needs the help.

Therefor it’s needed to have all information we could get from the asking person.

Most of that was absolutely clear albeit this section:

Let me tell you that it is clear for what your first two Actions are … you’ve explained that - but there is missing information.

Your first Action is a custom PlugIn and while I and maybe some others know that … there are many others who don’t - and they probably don’t have any custom PlugIns or the particular one that you use in your Macro you are posting here for getting help from others to troubleshoot your issue(s) with.

Please keep in mind that - if you ever in the future post Macros to get help on or share fully functional ones in the Macro Library section of this forum - you always give us all that is needed like any Custom PlugIn‘s destination Link when it’s from the web or if your version is older/ newer/ modified the PlugIn‘s code as a Zip like you’ve downloaded or created it.

Most of the time we are downloading the macros to test them on our machines - and if there are PlugIns in the Macro we don’t have the Editor will show us garbage instead of the PlugIn(s) until we install the missing PlugIn(s) on our Macs.

Another reason why this is important - let’s say you have Macro that’s not working as it needs to be and you use 10 PlugIns in that Macro and any one of them is not configured properly but you don’t know that …

If you’re posting this macro with the needed Information and mention the people behind the PlugIns you’ll probably get the answer why this isn’t working from any person that uses one or more or maybe even all the PlugIns you have in this particular Macro.
Sometimes it is possible to get additional tips on usage of the particular PlugIn(s) from the Creator(s).

I am sorry for this long reply … but it is fundamental information that you need to know about.

Have a nice day and again welcome to a wonderful community.

Greetings from Germany

Tobias

I apologize, I honestly have no idea what you're talking about though haha I was unaware I was using a custom plugin... every action in my macro was previously in my library, the top action is the Get Finder Path action. It's possible I downloaded it a long time ago an do remember I suppose, sorry about that.

This works great! Thank you!!

Glad to hear it—it's always a bit stressful writing something "in the blind" when I can't test it in the same way it'll be used :).

-rob.

Hey Olivia thanks for posting a screenshot of your Macro Editor with the actions selector pane open … if you just leave the word path in the search field and select the Third Party PlugIn Actions section on the left of the panel you’ll see the same Action. I have 55 custom PlugIns and used them many times over the years.

Maybe you could share the link to the PlugIn. It seems to be a very useful one.

What did you not understand? As this would get off topic just replay to me via PM.

Edit: made mistake posting a link to the wrong PlugIn

Greetings from Germany

Tobias