I have been searching all over the internet, forums, etc. to work out how to filter out folders by their name and rename / copy the remaining folder. In my example (that is most likely not even close to correct!) the user is asked to input a File Name and then the contents of the folder named Booking Files is filtered to remove folders that are named 360, Blue Skies, New, Watermark. The remaining folder (there will only ever be one) is then named with the File Name (that is declared as a variable) before being copied to the desktop.
I am attaching a screenshot of my Macros and would like to see how this type of thing is done without scripts so I can learn. Thank you in advance for any help
In case you are still working on this, here is a slightly amended version of what you were doing.
Moving folders containing files around using Keyboard Maestro is potentially a bit risky as there is no undo...
So, the below has a couple of safety checks added. First it checks if the file is actually a folder rather than a file (by checking the file type is "Directory"). And secondly (even though you said there would only ever be one odd folder) it stops after moving and renaming one folder (by using a Break from Loop Action).
Also, instead of using Matches 360|Blue Skies|New|Watermark (which would also match a folder called "360 test" or "360 Blue Skies" I used a list of "is not" tests. This can no doubt be done in Regex but that is beyond my Regex skill.
Hi @Zabobon and @Margate. The If action could be changed as follows. (Some might argue, however, that this version is more difficult to interpret.)
Aside: By convention, I suggest entering an Intentionally BlankComment action. Otherwise when coming back to a macro, one might wonder if the else case was left undone.
Hi @_jims that's great. I searched and couldn't find how to make the Regex only match exact matches in a multiple selection. So, the reason this works is that ^ says the start has to match and $ says the end of the phrase has to match, meaning in effect the whole phrase between each |?
^ means that the following character or string must be at the beginning of the line $ means that the preceding character or string must be at the beginning of the line.
They’re very useful, especially if you’re iterating over a bunch of lines that have a similar format.
I exclude where I can, but my RegEx is typically rather complex and uses a variety of capture groups... so as a default I go to non-capturing groups just to help visualize things better.