Hi everyone!
I have a problem that I don't know how to solve:
I have some folders whose name is divided into three parts: a 4-digit sequential number, a two or three word name, and a description. For example:
2564 Folder Name Folder Description
and I need to create new incremental folders with unique names.
I would like KM to read from that folder the highest number and create an incremental variable to add +1 each time
What I would like is to enter the "Folder Name" and the "folder description" with a prompt and for KM to create my folder. The problem is that I don't know how to make KM read the highest number of folders and how to make it a variable. Also because I would still like to have the ability to create folders manually.
I would also need to have the "Folder Name" as a variable without spaces: example "FolderName"
Will the format always be a number of some varying length at the start of the name, followed by a space?
In theory, this is doable with a macro that looped through the folder and stripped out the leading numbers into a list. Then sort the list descending and take the first line as the max folder number, add one, and off you go.
I took a shot at this, and this seems to work on my Mac. It's not a full solution, but it shows how you can find the next folder number based on the names of the existing folders.
You'll have to edit the "For Each" action to insert the folder you want to check. In the real macro, you could use the Prompt for File action to get the folder into a variable, then use that variable in the For Each.
This works by stripping the number off the name of each folder, and comparing that number to the current max folder number. If it's higher, set the new max folder number. Repeat until done with files, then add one and display the next folder number.
Thanks so much for the reply Rob!
The macro works very well if there are only numbered folders in the folder. However, inside the folder there are also other folders that do not begin with a number. Is there a way to search only folders that start with a number?
Oh, right, my fault: The regex test will fail if there aren't numbers at the start of the folder name. To fix that, click the Gear icon on the Search Using Regular Expression action, and disable the failure and warning on errors: