How would I go about making a macro that takes in selected files from Finder, and then renames them in place with a 001, 002 counter based on their creation date, from oldest to newest?
Hi @chrisaalid - this was asked before. See this thread:
You should note that the simplest solution given involves sorting the files by creation date in Finder before running the macro!
So, I'm trying to use this as the basis for a macro that lets me take a group of files selected in Finder and rename them with a counter in order of file creation date.
I can get the counter working, but I'm wondering if you had advice for for
Getting the %Local__FilePath% to appear on the renamed file. For some reason it won't and I can't figure out why.
Using Finder selection as an input. Finder selection on the For Each doesn't include sorting by creation or modification date, so I'm a little stumped.
Moderators note – macro based on input from this thread:
Rename Every File Inside a Folder with a Name Having 10 Digits - #2 by JMichaelTX
You’re not actually using a Finder selection action - you’re using an Items in Directory action. If you followed the advice I gave you in my previous post in your other thread about this you would be closer to the solution.
Please don't cross post the same problem in different threads.
(Keyboard Maestro Moderator)
He knows – see item number 2.
My bad - I thought the OP was still wanting to use Finder Selection as per their Post #1.
Hey @chrisaalid - you can change the sort order in the Items in directory; it’s currently set to “alphabetically”.
%Local__FilePath% is a PATH. You can't name a file with a path string.
You can't use bare variable names in text fields, such as the file path in the get file attribute action. You have to turn it into a text-token:
You're using this notation to represent variables in text-fields elsewhere:
This is a bad idea, and in my opinion should not be a legal format in Keyboard Maestro – because it's the same as text-tokens. You can't tell the difference at a glance, and that can make debugging much more difficult.
My advice is to always use the “proper” variable form:
The Finder-Selection plays little games according to what the sort is in the front window – as @tiffle's post indicates.
If you want to do the whole job yourself you'll have to get the file-creation-date, associate it with the file-path, and sort. Something like this:
From there you can find/replace the creation-date to remove it and then iterate through the list of paths which are now in the correct sort order.
I'll leave that as an exercise for the user.
As usual There's More Than One Way to Do It.
He does – he just doesn't know how.
Between you and me he now has a couple of different methods to use.