I would like to load the latest file in a directory (regularly, as fast as possible), where I output some scientific figures and plots in vector format. Is it possible to either:

  1. Load the most recent file into the currently open one
  2. Load the most recent file into a new document?

with the click of a button / or hotkey - and if yes, how? Reading the documentation I could not find a hint to do these quasi advanced things. Ideally, a syntax language would be available for powerusers, but I coulnd't find this.

  • 1
    Besides actions you can use scripts (similar to javascript). Anyway, in the Open or Place dialog, can't you just sort your files according to Date modified? Illustrator will remember the folder and the sorting method so a new file will appear at the top. Then it's just two clicks and a double-click.
    – Wolff
    Jan 21, 2021 at 23:26
  • oh, so sorry, I slowly realize the extent of my noob-level in Illustrator. I will look this up, action scripts. Thank you Jan 21, 2021 at 23:43
  • 1
    Have a look at Adobe's resources here. I'm working on a simple example to get you started.
    – Wolff
    Jan 21, 2021 at 23:49
  • What do you mean by ‘latest file’ and ‘most recent file’? Going by the fact that you accepted @Wolff’s answer, it seems like you mean ‘most recently modified file in a given folder’, but I would immediately understand both to mean ‘the file most recently opened in Illustrator, regardless of where it’s located’ (i.e., the one that appears at the top of the Recently Opened Files submenu in Illustrator). Could you clarify/specify this in your question, just so future readers are not misled by an answer that does something other than what they’re expecting? Jan 23, 2021 at 11:48

1 Answer 1


A script to place the most recent file from a folder

Here is a simple script that places the most recent file from a folder into the currently active Illustrator document. Every line is explained with a comment.

// the folder containing the files to place (change the path)
var folder = new Folder('D:/myFolder');

// an array of the files in the folder
var files = folder.getFiles();

// sort the files according to when they were last modified 
files.sort(function(a, b) {
    return a.modified.valueOf() < b.modified.valueOf() ? 1 : -1;

// small alert box to show which file is loaded, useful to debug
// alert(files[0]);

// the most recent file in the folder
var mostRecentFile = new File(files[0]);

// the active document
var document = app.activeDocument;

// a container for all placed items in the document 
var placedItems = document.placedItems;

// add a new placed item
var newPlacedItem = placedItems.add();

// link the placed item to the most recent file
newPlacedItem.file = mostRecentFile;

As mentioned in one of the comments you of course need to specify the folder you want to use. The script is pretty raw. Tweaks and checks might be needed depending on your workflow. For example, the script will fail if the folder contains a newly created subfolder.

How to use the script

  • Copy the script text above and paste it into a text editor.

  • Save the script as a .jsx file.

  • In Illustrator, use File > Scripts > Other Script, browse to the script file and press Open to run the script.

How to run the script with a function key

The only way I know to assign a function key to a script is a bit quirky. If someone knows a better way please edit.

  • The File > Scripts menu contains some featured scripts. In order to record an action executing a custom script, you need to add your script to that list. This is done by copying the script to the folder containing those featured scripts. On my computer they are in D:\Program Files\Adobe\Adobe Illustrator 2020\Presets\en_US\Scripts.

  • Now you probably need to restart Illustrator before your script is added to the menu.

  • In the Actions panel, click Create New Action, assign a Function Key of your choice and click Record.

  • In the sandwich menu of the Actions panel, choose Insert Menu Item, search for the name of your script and click OK when you have located it.

  • In the Actions panel, click Stop Playing/Recording to end the recording.

Now you should be able to place the most recent file with one key press!

  • crazy. will test and report back Jan 23, 2021 at 1:10
  • It seems the script worked for you since you accepted! I've added information on how to run the script with a function key.
    – Wolff
    Jan 23, 2021 at 2:09
  • It almost worked out of the box. I submitted an edit to your answer to fix it an error I got (the linked feature didn't work for me and I don't need it, so I disabled it for my purposes). JavaScript does not like backslashes of Windows directories in their strings - make sure to just circumvent the problem (on newer Windows machines) by simply using forward slashes (like is standard on UNIX based machines since forever) Jan 24, 2021 at 6:42
  • I approved your edit, but I don't really understand it. Besides adding an alert showing the path of the file that's going to be placed, the only thing you've changed seems to be that you wrap files[0] in a new File() object. I can't understand why that is necessary since it should already be a File object and not just a String. I didn't have any backslash problems on my Windows machine as I used forward slashes in the folder path. You also talk about disabling the "linked feature". I don't understand what you mean by that and can't see that you've done it.
    – Wolff
    Jan 24, 2021 at 10:16
  • 1
    @user2305193 if the file is a SVG then yes.
    – joojaa
    Jan 25, 2021 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.