I don't know how much information is necessary and useful here... I'll keep it brief for now. Essentially, I'm asking for help creating a macro that sorts documents by name in an app.
In the screenshot above, documents are sorted by a number before the name. If I want to place “James” between ‘Harry’ and “George,” I change the number for “James” to 150.
Of course, I can do this manually. However, it would be ideal to have a macro that (after a trigger) asks me for a number when “James” is selected.
The macro should leave the original name unchanged but change the number as I enter it.
Perhaps someone has a much better idea for achieving the same thing. If so, I would be grateful for a tip Thanks.
What is the idea of changing number in Jame’s position? Do you want to have sorted list based on 2nd and 3rd word but still have the numbers in beginning? If yes, remove 1st word, next sort the list and add number prefix (increment by defined step). I can help you in defining such process?
@griffman It could be the Finder. This app works exactly the same when sorting by name is selected. Perfect for testing.
Yes, please
As for the rest, I don't know how I could explain it any better than I already have.
The number before the name is a “tool” for changing the position of a document in a list without changing the name of the document.
In my imagination, I select a document, press a shortcut key, and now, for example, a small window appears. I enter a number, press Enter, and the selected document gets a new number in front of its name. I have no idea if that's possible.
and rename that files (in the same directory) based on order got after sorting file names without numeric prefix but add newly created numeric prefix to the file name like
The initial value of new prefix is assigned to KM Variable local_initPfx. If that value is less then 100, then new number prefix is formatted with 3 digits (with zeros in the beginning).
The core solution is in form of python script. In macOS exists python 3.9 what is enough for that script, but if you have any other (probably later version) it also should works.
Script takes list of files from standard input.
Inn may case I trigger it from StreamDeck, so please change trigger to your environment.
Because selection from Finder represents files as full path, first part of script split file names to based and base name and check if more then one based exists in the input. In such way script can’t be usable and finish without further actions.
The rest is fully described in comments but if you need help to understand any part, just ask on the forum.