I'm trying to script a file rename macro using a RegEx expression. I've tested the RegEx in Visual Studio Code, and the expression matches the test text:
RegEx: ^(\D+)(\d\d\d\d).+$
Test Text (typical file name): Galaxy Quest 1999 1080p BluRay Backup Complete
But I keep getting an error in Keyboard Maestro that the RegEx failed to match. Here's my script so far. (Note in the file name, the spaces were originally periods.)
Please post your macro so we can test it ourselves. File > Share macro to forum > copy the uploaded URL into this thread. (Or something close to that at least - you’ll work it out)
It doesn't look like you ever put the parent and base parts back together to create %Variable%VarName% upon which the regex search is presumably supposed to take place.
Posts #7 through #10 moved here from a separate topic – 2022/03/18 18:28 CDT – ccs
Hi All,
I started a previous topic but didn't know you could upload a macro to the forum from KM.
The RegEx expression I came up with is just to search the file name, separated from the file path and the file extension. I put the path, file name, and extension back together in the last step of the Macro.
The problem I'm having is that although the regular expression works on test text when I use it in Visual Studio Code, it is not working in Keyboard Maestro for some reason.
Incidentally, there's no need to create a separate thread when you upload a macro – just copy the tags in the draft new topic created by File > Share > Keyboard Maestro Forum