Home > InDesign Scripts > Drop-down library opener

Drop-down library opener

Do you have lot of libraries? You need to open them but you are tired of searching right folder and stuff? This is simple and effective solution for opening libraries that are located in same folder. This script is published on Adobe’s InDesign scripting forum by me🙂 Also, you can build it in some bigger script/dialog.

var myWorkFolder = Folder("/d/!myWork");
var showWorkFolder = Boolean(true);

var strWinTitle = String("Library opener");
var strWorkFolder = String("Working folder:");
var strWorkFolderNotExist = String("Working folder not exists:");
var strSelectLib = String("Select library:");
var strNoFiles = String("-- No libraries found --");

///////////////////////// SCRIPT /////////////////////////

var myWorkFolderExist = Boolean(myWorkFolder.exists);
var myFiles = myWorkFolder.getFiles("*.indl");
var myFilesNo = myFiles.length;
var myLibFiles = Array();
if(!myWorkFolderExist)strWorkFolder = strWorkFolderNotExist;

if(!myFilesNo){
 myLibFiles[0] = strNoFiles;
}else{
 for(var i=0; i < myFilesNo; i++){
      myLibFiles.push(myFiles[i].displayName.substr(0, myFiles[i].displayName.lastIndexOf(".")));
 }
}

var myDialog = app.dialogs.add({name:strWinTitle, canCancel:true});
with(myDialog){
    with(dialogColumns.add()){
         if(showWorkFolder){
              with(dialogRows.add()){
                   with(borderPanels.add()){
                        with(dialogColumns.add()){
                           staticTexts.add({staticLabel:strWorkFolder});
                        }
                        with(dialogColumns.add()){
                           staticTexts.add({staticLabel:myWorkFolder.fsName});
                        }
                   }
              }
         }
         with(dialogRows.add()){
              with(borderPanels.add()){
                   with(dialogColumns.add()){
                        staticTexts.add({staticLabel:strSelectLib});
                   }
                   with(dialogColumns.add()){
                        var myLib = dropdowns.add({stringList:myLibFiles, selectedIndex:0});
                   }
              }
         }
    }
}

if(myDialog.show() == true){
     if(myFilesNo){
          app.open(File(myFiles[myLib.selectedIndex]),false);
     }
}

myDialog.destroy();

I tried to keep variables readable so we can easily alter script to our needs. Let’s go through variables. Starting with defining working folder with myWorkFolder, next showWorkFolder is just small dialog feature for show/hide working folder in dialog (for example if you don’t want your client to see where libraries are), next five string variables are for defining window title and stuff, so you can easily translate it to other language. Basically we are done with settings. There is one little feature myWorkFolderExist that checks if folder exists, and if false it replaces strWorkFolder string with strWorkFolderNotExist.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: