Skip to content

Instantly share code, notes, and snippets.

@trych
Last active September 25, 2024 11:04
Show Gist options
  • Save trych/e9dceddf3e676e04e848 to your computer and use it in GitHub Desktop.
Save trych/e9dceddf3e676e04e848 to your computer and use it in GitHub Desktop.
InDesign Remove Recent Items StartUp-Script
#target InDesign
#targetengine "removeRecentItems"
var menuName = "Remove Recent";
var removeAction = app.scriptMenuActions.add(menuName);
removeAction.eventListeners.add("onInvoke", removeRecentItems);
removeAction.eventListeners.add("beforeDisplay", recentAvailable);
var mainMenu = app.menus.itemByName("$ID/Main");
var fileMenu = mainMenu.submenus.itemByName("$ID/FileDestinationPanel");
if (fileMenu.submenus.itemByName("$ID/Open &Recent").isValid && (!fileMenu.menuItems.itemByName(menuName).isValid)) {
fileMenu.menuItems.add(removeAction, LocationOptions.AFTER, fileMenu.submenus.itemByName("$ID/Open &Recent"));
}
function removeRecentItems () {
var userOR = app.generalPreferences.openRecentLength;
app.generalPreferences.openRecentLength = 0;
app.generalPreferences.openRecentLength = userOR;
return;
}
function recentAvailable(event) {
var action = event.parent;
if (fileMenu.submenus.itemByName("$ID/Open &Recent").isValid) {
action.enabled = true;
} else {
action.enabled = false;
}
return;
}
@trych
Copy link
Author

trych commented Dec 21, 2015

Adds a menu entry in InDesign's file menu to remove all items from the "Open Recent" list.

If you want to use this in InDesign, download and add the file to your startup script folder (InDesign XX -> Scripts -> startup scripts).
Restart InDesign and you should now have a menu entry available in your File menu named Remove Recent. Click it to remove the list of recently open files. The menu entry is now deactivated since there are no files left to remove, but as soon as there are new files in the list the option reactivates.

If you want to have a different name for your menu entry (matching your language for example), simply change the value of menuName from "Remove Recent" to something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment