Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

"Open Recent" topmost file as part of an action

Engaged ,
Jan 17, 2023 Jan 17, 2023

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.

 

 

 

 

TOPICS
Actions and scripting
767
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 18, 2023 Jan 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!");
}

 

Translate
Adobe
Community Expert ,
Jan 18, 2023 Jan 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!");
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2023 Jan 19, 2023

@Guy Burns 

 

So how did the script go for you?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 13, 2025 Jan 13, 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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2025 Jan 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:
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2025 Jan 14, 2025
quote

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.

 


By @Guy Burns

 

Then the previously posted script may not suit this new criteria.

 

So are you using Save As and not Save a Copy?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 14, 2025 Jan 14, 2025

In all my Actions, under the "Save" step it says:

 

as:  JPEG

in:  A-Data:Slide Temp:

With Copy

 

I'll try the script and see how it goes. I can alter my workflow to only work on one file at a time – I think.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2025 Jan 14, 2025

@Guy Burns 

 

If you can clearly and concisely explain your process step by step, I'm sure that a new script can be written.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 14, 2025 Jan 14, 2025

I've just put your script through its paces on a test file, and it works. Placed at the end of my Actions that crop and save to other formats, it causes PS to revert to the Tiff file at the head of the "Recent Files" list.

 

Now I'll put it through some real life tests over the coming weeks. Instead of my previous method of…

  • saving as Tiff LZW
  • running the Action
  • re-opening the Tiff
  • saving as Tiff Zip…

I can now Save As when the Action finishes, and choose Tiff Zip.

 

Ques: Is there any way to automate that last step, the save as Tiff Zip?  – but in a way that does not lock up PS.

 

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2025 Jan 14, 2025

Saving the master file without closing then doing something else and then reverting might be an option over closing and reopening.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2025 Jan 14, 2025
LATEST
quote

Ques: Is there any way to automate that last step, the save as Tiff Zip?  – but in a way that does not lock up PS.

 


By @Guy Burns


When I previously tested actions and scripted saves, they always saved in the foreground. It appears that background saving is only triggered by user input.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines