Your prescription for increased productivity and profitability
If you switch to a different folder while working with a project, the computer loses track of your current folder. When you need to select image files or whatever for placing, you end up having to navigate to find the folder.
Folder-diving is not my favorite thing so I use a script to locate the folder for me. In AppleScript the default location parameter for the choose file command does this for you.
set promptStr to "Select images for placing" set defaultFolder to path to home folder from user domain set fileList to choose file with prompt promptStr default location defaultFolder ¬ with multiple selections allowed without invisibles
ExtendScript (JavaScript) does not have a corresponding parameter for its Open Dialog method. The closest thing you will find in the Object Model Viewer is Folder.current. This gives you the path to the current folder but it does little to give you a default folder for selecting files. The trick is to use the openDlg method for the folder object.
var imageFolder = Folder.desktop; var promptStr = "Choose image files for placing"; var fileFilter = "*.*"; var allowMulti = true; var fileList = imageFolder.openDlg(promptStr, fileFilter, allowMulti); fileList;
With this in mind, if you are consistent in setting up new projects with a folder structure that includes an “images” folder inside of the project folder, you can use the path to your InDesign document to locate the images folder for you.
In AppleScript (assuming document 1 is open and has been saved)
set promptStr to "Choose image files for placing" set allowMulti to true tell application "Adobe InDesign CS6" set docRef to document 1 set projFolder to file path of docRef as string set imageFolder to projFolder & "images" end tell try set errStr to "Image folder not found" set dFolder to imageFolder as alias set fileList to chooseFile(promptStr, dFolder, allowMulti) on error errStr display alert (errStr) return end try
--returns alias list of files chosen; errors if user cancels on chooseFile(promptStr, dFolder, allowMulti) set fileList to choose file with prompt promptStr default location dFolder ¬ multiple selections allowed allowMulti without invisibles if fileList = false then error ("User Cancelled") end if return fileList end chooseFile
For ExtendScript (again assuming document 1 is open and has been saved)
var promptStr="Choose files for placing"; var fileFilter="*.*"; var allowMulti=true; var docRef= app.documents.item(0); var projFolder=docRef.filePath; var imageFolder=Folder(projFolder + "/images"); if (!Folder(imageFolder).exists) { alert ("Image folder not found"); exit(); } try { var fileList=chooseFile(imageFolder, promptStr, fileFilter, allowMulti); fileList; } catch (e) { alert ("Error " + e); exit(); }
//Has user choose files from current folder function chooseFile (imageFolder, promptStr, fileFilter, allowMulti){ var fileList = imageFolder.openDlg(promptStr, fileFilter, allowMulti); if (fileList==null) { throw ("user cancelled"); } else { return fileList; } }
Use a script with this functionality to save you from having to folder dive the next time your computer system loses sight of your project folder.