Open the Most Recently Added File in a Specific Folder?

Below is the action I'm using:

screenshot-08-19-2021-17-49-53

My question is this: Is there a token or variable that would allow this action to open the most recent file in the specified folder, or, if not, is there some other way of achieving this?

No token, but you can use the For Each action to create a variable that will contain the path to the most recently modified (or created, or added, etc.) file in a specified folder, then use the Break From Loop action to ensure the macro stops after only opening that one file:

Open Last Modified File in Folder.kmmacros (1.9 KB)

1 Like

Gg's answer seems correct, but I want to offer a little more information and ask a question of you.

UNIX has a timestamp on every file. In fact it has three timestamps: (1) The last modification time; (2) the last change time (which is slightly different from modification tmie, and (3) the last access time. I think OS X also has a (4) file creation time. Although that may depend on which file system your Mac is configured with.

So now you have to say what you mean by "allow this action to open the most recent file." Most recent what? Most recently changed? Most recently created? Most recently read? Your response might change Gg's answer a bit. I think he may have assumed something that may not be correct.

Thanks! :slightly_smiling_face:

1 Like

I meant most recently added, but that option is also available in the action that Gg showed, so I'm good. :slightly_smiling_face:

screenshot-08-20-2021-12-43-10

1 Like

Hey Folks,

Remember that most recent item is contingent upon context.

Personally I usually define it as most recently added, but that can change depending upon my use-case.

image

Don't forget – there are a number of sort options for this action:

image

-Chris

1 Like

Okay. Upon reflection, I can now see why your words probably meant that. But I legitimately didn't realize that the first couple of times I read your post.

That's understandable, I wasn't really as clear as I should've been.