Skip to main content
Inspiring
January 18, 2023
Answered

"Open Recent" topmost file as part of an action

  • January 18, 2023
  • 10 replies
  • 983 views

Is it possible to open the top most file under "Open Recent" files, as part of an Action? But not locked to a particular file when the Action was created, but is actually the most recent file opened.

 

The reason I want to do this is because there seems no other way to do what I want. A couple of years ago I asked about a certain action that I need, and there was no solution, so I'll try again.

 

I have about 30 actions that save images in a variable format and size, e.g. jpg 1080P, or PSD 1920W (1920 wide), and so on. These files are destined for Premiere, but the original file I want to save as Tiff > Zip just before I run the relevant Action.

 

The problem is… Tiff > Zip can take up to a minute to save, whereas Tiff > LZW usually takes only seconds, meaning I can jump straight into Premiere to see the result, instead of waiting for the Tiff > Zip file to save.

 

These are the typical steps I take when using an Action:

  1. The file is edited.
  2. I save the file as LZW – fast
  3. I run the Action
  4. I open Premiere and the file is already updated.

 

I want to generate new Actions that, right at the end (after the jpg or whatever has been saved), that the most recent file is then opened (the same file I was working on) and automatically saved and closed as Tiff > Zip. i.e. it runs in the background while I'm inside Premiere looking for the next file to edit.

 

My Actions can be downloaded here. It's only the ones starting with "Crop" that I'm talking about. To see how they work, you have to have a selection in place before the Action is run.

 

Thanks in advance for any suggestions.

 

 

 

 

Correct answer Stephen Marsh

@Guy Burns 

 

The following "action helper script" will open the most recent file. It can be recorded into an action as a step.

 

#target photoshop
if (app.recentFiles.length > 0) {
    try {
        app.open(File(app.recentFiles[0]));
    } catch (e) {
        //alert("The file is missing or an unexpected error occurred!"
    }
} else {
    //alert("The Open Recent list is empty!");
}

 

10 replies

Stephen Marsh
Community Expert
Community Expert
January 19, 2023

@Guy Burns 

 

So how did the script go for you?

Guy BurnsAuthor
Inspiring
January 14, 2025

I only just saw your reply. I wasn't notified by email, or the email went to spam.

 

I  entered the script into Apple Script, but I'm not allowed to Save, Run, or Compile it (see attachment). I know very little about scripting, but if it can be fixed, let me know and I'll try it. Over the next 18 months I expect to run the Actions several thousand times, so the script would be a great help.

 

A Concern

One thing I'm concerned about is the "opening the most recent file" thing. My wording was unclear. I may have several files open in PS, and the one I'm actually about to run the Action on, may not be the most recent file that I opened. The Action has to re-open the same file that it started on.

 

To reword my original post:

I want to generate new Actions that, right at the end (after the jpg or whatever has been saved), that the same Tiff file I was just working on (and that I just saved) is automatically opened again, saved as Tiff > Zip, and closed. i.e. it runs in the background, while I go inside Premiere to look at the result.

 

Another concern

Thinking more about this, what I want may not be desirable in an Action because I'll be locked out of doing anything else in PS while the file is re-saved as Tiff > Zip. That could take a minute.

 

Me smarter than computer!

How come this flash computer I've got, can't automatically do what I can easily do manually:

  1. Save the file as Tiff > LZW (takes seconds)
  2. Run the Action (takes seconds)
  3. Re-open the file (takes me seconds to look through the "Recent Files" list and find it)
  4. Save as Tiff > Zip (takes the computer a minute). But I'm free to do anything else – work on another PS file or jump into Premiere.

 

Anyway, if you can think of a method, please respond.

 

Stephen Marsh
Community Expert
Community Expert
January 14, 2025
quote

I  entered the script into Apple Script, but I'm not allowed to Save, Run, or Compile it (see attachment). I know very little about scripting, but if it can be fixed, let me know and I'll try it.


By @Guy Burns

 

The code is not AppleScript code, it's ExtendScript/JavaScript.

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor or AppleScript Editor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

 

Only paste the source code into plain text editors, not rich text or word processing apps. If using Apple TextEdit.app, ensure the Format menu is set to Plain Text mode, not Rich Text mode.

 

Scripts are installed in the /Presets/Scripts folder

Mac OS Example:

  • /Applications⁩/Adobe Photoshop CC 2019⁩/Presets⁩/Scripts
  • /Applications/Adobe Photoshop 2021/Presets/Scripts
 
(If this path does not match your version, it should be a simple enough process to find the correct folder using this guide)

Win OS Example:
  • C:\Program Files\Adobe\Adobe Photoshop CC 2018\Presets\Scripts
  • C:\Program Files\Adobe\Adobe Photoshop 2021\Presets\Scripts
 
(If this path does not match your version, it should be a simple enough process to find the correct folder using this guide)

Alternatively, select File > Scripts > Browse and navigate to the script file.
 
If you prefer videos, William Campbell has some on how to install scripts here:
Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
January 18, 2023

@Guy Burns 

 

The following "action helper script" will open the most recent file. It can be recorded into an action as a step.

 

#target photoshop
if (app.recentFiles.length > 0) {
    try {
        app.open(File(app.recentFiles[0]));
    } catch (e) {
        //alert("The file is missing or an unexpected error occurred!"
    }
} else {
    //alert("The Open Recent list is empty!");
}