Skip to main content
Inspiring
July 24, 2015
Answered

script for "Open Recent"

  • July 24, 2015
  • 1 reply
  • 1334 views

Looking for a script that will open the most recent item from the "Open Recent" list?

This smart fellow made this script that lets you open a selection from the Open Recent list:

http://morris-photographics.com/photoshop/scripts/open-recent.html

...but I want it to skip the dialogue window and just open the most recent.  Can anyone please fix this attempt I made?

var recentItems = [];

var len = recentFiles.length;

for (var i = 0; i < len; i++) {

     recentFile = recentFiles;

     if (recentFile.exists) {

          recentItems.push(recentFile);

          if (recentItems.length == 1) {

               break;

          }

     }

}

len = recentItems.length;

1 = Math.min(1, len);

app.open(File(recentFile));

Cheers!

This topic has been closed for replies.
Correct answer MR74270

Please, try this :

#target photoshop

app.bringToFront();

var maxFiles = 10;

var recentItems = [];

var len = recentFiles.length;

for (var i = 0; i < len; i++)

{

    recentFile = recentFiles;

    if (recentFile.exists)

    {

        recentItems.push(recentFile);

        if (recentItems.length == maxFiles+1)

        {

            break;

        }

        app.open (File(recentItems));

    }

}

1 reply

MR74270
MR74270Correct answer
Inspiring
July 25, 2015

Please, try this :

#target photoshop

app.bringToFront();

var maxFiles = 10;

var recentItems = [];

var len = recentFiles.length;

for (var i = 0; i < len; i++)

{

    recentFile = recentFiles;

    if (recentFile.exists)

    {

        recentItems.push(recentFile);

        if (recentItems.length == maxFiles+1)

        {

            break;

        }

        app.open (File(recentItems));

    }

}

Inspiring
July 26, 2015

Nicely done, michelr,

The recent files open!  Your code seems to open multiple files.  For my needs I tweaked it to Open the latest files only.

I changed your line

    app.open (File(recentItems));

to

    app.open (File(recentItems[0]));

Thanks for the help!

MR74270
Inspiring
July 27, 2015

Hi Wootie,

I wrote the general algo.  If you change the value of maxFiles (in your case : var maxFile=1;) you will open the last file.

Best regards. .