How to prompt user to select multiple files in file dialog using scripts

Hi, is there a way to allow user to select multiple files inside the file dialog using scripts? So not just something like "*.ai" or "*.eps" but where the user can actually use their shift key to select a batch of files inside the file dialog and then the script would process each one.
Thanks!

// Main Code [Execution of script begins here]
here's what I have so far. it would also be nice to not have illustrator stop at errors.. right now, it skips dialogs but on errors, it still stops.
// uncomment to suppress Illustrator warning dialogs
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts, folderName;
var fullPath = "";
var finalSlash;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator .ai files you want to convert to PDF');
f = find_files(sourceFolder);
function find_files (dir)
    return find_files_sub (dir, []);
function find_files_sub (dir, array)
    var f = Folder (dir).getFiles ("*.*");
    for (var i = 0; i < f.length; i++)
        if (f[i] instanceof Folder)
            find_files_sub (f[i], array);
        else
            if (f[i].name.slice (-3).toLowerCase() == ".ai"          || f[i].name.slice (-4).toLowerCase() == ".eps")
                    //convert the array-listing to a string so we can manipulate it
                    fullPath = String(f[i]);
                    //find the position of the last / to indicate where the filename starts
                    finalSlash = fullPath.lastIndexOf("/");
                    //get the foldername by "slicing" from start to where finalSlash is located
                    folderName = fullPath.slice(0, finalSlash).toLowerCase();                   
                    sourceDoc = app.open(f[i]); // returns the document object
                    // Call function getNewName to get the name and file to save the pdf          
                                                  targetFile_PNG = getNewName(".png");
                                                  if(targetFile_PNG.exists) {
                                                  } else {
                                                            pngExportOpts = getPNGOptions();
                                                            sourceDoc.exportFile(targetFile_PNG, ExportType.PNG24, pngExportOpts );
                    targetFile_PDF = getNewName(".pdf");
                    pdfSaveOpts = getPDFOptions();
                                                  sourceDoc.saveAs(targetFile_PDF, pdfSaveOpts );
                                                  targetFile_SVG = getNewName(".svg");
                                                  svgSaveOpts = getSVGOptions();
                                                  sourceDoc.exportFile(targetFile_SVG, ExportType.SVG, svgSaveOpts );
                    sourceDoc.close();
                    array.push (f[i]);
getNewName: Function to get the new file name. The primary
name is the same as the source file.
function getNewName(ext)
    var ext, docName, newName, saveInFile, docName, finalDot
    var loop = 0;
    docName = sourceDoc.name;
    ext = ext; // new extension for pdf file
    newName = "";
    finalDot = sourceDoc.name.lastIndexOf(".");
    while(loop < finalDot)
        newName += docName[loop];
        loop = loop + 1;
    newName += ext; // full pdf name of the file
          newName = newName.replace(" [Converted]","");
    // Create a file object to save the pdf
    saveInFile = new File( folderName + '/' + newName );
    return saveInFile;
getPDFOptions: Function to set the PDF saving options of the
files using the PDFSaveOptions object.
function getPDFOptions()
    // Create the PDFSaveOptions object to set the PDF options
    var pdfSaveOpts = new PDFSaveOptions();
    // Setting PDFSaveOptions properties. Please see the JavaScript Reference
    // for a description of these properties.
    // Add more properties here if you like
    pdfSaveOpts.acrobatLayers = false;
    pdfSaveOpts.colorBars = false;
    pdfSaveOpts.colorCompression = CompressionQuality.AUTOMATICJPEGHIGH;
    pdfSaveOpts.compressArt = true; //default
    pdfSaveOpts.embedICCProfile = false;
    pdfSaveOpts.enablePlainText = false;
    pdfSaveOpts.generateThumbnails = false; // default
    pdfSaveOpts.optimization = true;
    pdfSaveOpts.pageInformation = false;
    pdfSaveOpts.preserveEditability = true;
    return pdfSaveOpts;
function getSVGOptions()
          var svgSaveOpts = new ExportOptionsSVG();
          //just using defaults aside from what's written below
  //see http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csawlib/com/adobe/illustrator/ ExportOptionsSVG.html
  svgSaveOpts.embedRasterImages = true;
  svgSaveOpts.sVGTextOnPath = true;
          return svgSaveOpts;
function getPNGOptions()
          // Create the PDFSaveOptions object to set the PDF options
          var pngExportOpts = new ExportOptionsPNG24();
          // Setting PNGExportOptions properties. Please see the JavaScript Reference
          // for a description of these properties.
          // Add more properties here if you like
          pngExportOpts.antiAliasing = true;
          pngExportOpts.artBoardClipping = false;
          pngExportOpts.horizontalScale = 100; // scaling to 350%
          pngExportOpts.saveAsHTML = false;
          pngExportOpts.transparency = true;
          pngExportOpts.verticalScale = 100; // scaling to 350%
          return pngExportOpts;

Similar Messages

  • How to allow user to select pdf file on local machine and populate field with file name only

    Folks,
    I have a project requirement that I am stumped on.  I am admittedly a novice, so forgive questions that may seem obvious.
    My requirement is a form running on a client system where the user can click a button and select a PDF file name from a PDF on their local machine and then populate a form field with that file path & filename.  The file names vary between all machines, so there is no static list.  Note that the PDF is not embedded, nothing is executed, I simply need the file name.
    There are several of these on a form (20+), so manual name entry is too error prone.   I would like to use a 'browse' type dialog, but can not figure out how to implement it.
    I've looked at app.browseForFile, but the users can not install a javascript file in their adobe folder or any other files;  the functionality has to be integral with the original PDF. 
    Functionally, this is no different from the image object file browse, except that I need a PDF instead of an image file, so there doesn't seem like there should be a security issue that is any different from those surrounding the image object.
    I've been stumped on this for the entire week, and I have a deadline rapidly approaching, so any examples or suggestions (please remember I'm a novice) would be greatly appreciated! 

    Thanks for the reply Paul - do you have any sample code of how to attach the PDF?  Or how the user can select a PDF to open?  I might be able to attach it, retrieve the file name, and then un-attach it.
    Alternatively, do you know how to retrieve the file name from the imagePath object?  It will let you select PDF files, but I can't find info on how to retrieve the file name.   It should be the way you would retrieve the file name for an image.
    As a novice in this, thanks for your help and patience!

  • Prompt user to select multiple objects within an action

    Hi there,
    In illustrator, is it possible to select multiple objects within an action or prompt the user to do so when needed ?
    I know about the note trick but I am not quite happy with this one. I would like another solution if there is any.
    Thanks !!

    In order for a macro (Action) or script to select something, it has to have access to some criteria by which to target the object(s). Actions are much more limited in this regard than scripts, but there are some "hooks" you can employ.
    For example, Actions will record the assignment of a Note in the Attributes palette. So if your Action at least starts with the object(s) of interest selected, you can take that opportunity to record the entry of a string in the Note field. Thereafter, if the object(s) become deselected, the Action (or another Action) can re-select them by means of the Select Object(s)... step. When manipulation of the target object(s) is done, you can record changing its note to nothing, to prevet its being seleced by the same Select Object(s)... step later.
    JET

  • How to allow user to select multiple languages in ESO

    Hi Expert,
    I need your help on ESO languages capability.
    I need to allow end user to change language options like from english to chinese or from chinese to spanish. Now we have this option only tied to profile like user can select only one language in profile in "display langauge" option.
    Please help me how to do this in ESO as i am new to this application.
    Thanks much for your cooperation and help in advance.
    Regards,
    Gurvi.

    use transaction SE63 in order to translate the texts -> menu Translation / ABAP Objects / Short texts then choose OTR in tree
    to find object name, use the matchcode and specify the development class (or package) as collection
    SAP will display texts according to logon language of user

  • How do you select multiple files on a macbook pro?

    Can anyone tell me how to select multiple files at one time?  I am so frustrated with the way macbook pro works that I really regret buying it.  I hate that you can't select multiple files, and that my contact stuff keeps changing.  It is certainly not like I was told...that I would never want to use a PC again.  I would not buy another apple computer.  I spent a lot of money to NOT be able to do things that I have always done with ease.  Every time I think I have something figured out, it doesn't work the next time I go to use it in another program.  If anyone has an answer to this, I would sure appreciate it. 
    And all of these so called wonderful updates to the operating system on all mac products have left me frustrated and liking my apple products far less than I did before.  On my iphone I had to make the texts just huge to even be able to see the white writing on a blue background.  Not sure who made these designs, but from my perspective, I can tell you they certainly weren't thinking about being user friendly in any way when they did it.  So disappointed in all of my devices!  I do not enjoy using my computer, ipad, or iphone even close to what I did before.

    This is some information on the Finder.
    http://support.apple.com/kb/ht2470
    To select multiple files you can use the shift key with the mouse if they are in a contiguous list or the CMD key with the mouse if you have breaks in that list. You can also use the mouse to drag over the files you want to select.
    The Macs are easy to use, I have used many versions of Windows, Linux and other operating systems and I find OS X is far the easiest, but that is me.
    There are many instructional videos and texts on Apples web site and if you are near to an Apple store they do classes to help.
    Hope you get used to it.

  • How do you select multiple files to drag

    How do you select multiple files to drag from one folder to another? Is there a command?

    Open the folder which has the contents you want to transfer.  Press COMMAND 'A' and then all of the data should be highlited in blue.  Drag it to the new folder.
    If only certain files are to be transferred, then you have to select them (COMMAND 'A')  individually and the drag them as a group to the new location.
    Ciao.

  • How do you select multiple files at one time

    How do you select multiple files at one time

    Select one, and then either command-click another, or in list/column view, Shift-click the item at the other end of the range you want to select. Alternatively, click on a spot in the screen and drag the cursor until all the files are selected.
    (114308)

  • How do I select multiple files under "Get File Info"and lock or unlock all?

    How do I select multiple files under "Get File Info"and lock or unlock them all? It seems to do it automatically when I have 10 or more selected. But how do I lock or unlock 5 or 6 files in one swoop? Thanks

    Select the desired files then press OPTION and select Show Inspector from the Finder's File menu.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

  • How to select multiple files with Trackpad

    I am new to Mac and to the Trackpad. I apologize if this has been posted.
    When I work on a Windows PC, if I want to select multiple consecutive files I can click on the first file, press and hold SHIFT and then select the last file and all files in between are selected.
    I tried that using the Trackpad and it doesn't seem to work the same way. Is there another key combination? I can select multiple files by either using SHIFT (on Picasa website for example) and then tap or by holding COMMAND and then tap each individual file. But how do I select multiple files similar to Windows, clicking first file pressing a key and clicking the last file.
    Thanks in advance for any input on this.

    If you choose 'view as list', you can use the shift-key. Select an item, press the shift-key while you press an item below and all the items between are selected.

  • Super Basic, How do I select multiple files?

    Super Basic, How do I select multiple files?  I can click on one, but I want to select an entire group of files.  On a PC I would use the control or shift keys, or just use the mouse to draw a box around them, but nothing seems to work.

    It works here using the Shift key (after selecting the first item, hit Shift key while clicking on another). If you display your Finder windows as list or columns, it's extra easy: You click on the first item, then hit Shift and click on the last item - all of them will be selected.

  • How to select Multiple files in ADF?

    I have a requirement to select multiple files in my aaplication.
    I know af:inputfile can select only one file and putting more af:inputfile component on the screen is not an option.
    Can someone please help me on this
    Thanks
    RJ

    Hi,
    multiple file uploads is a feature of JDeveloper 12c (upcoming)
    Frank

  • Selecting multiple files with mouse now wonky

    Using Windows 8.1 on HP machine
    All updates up-to-date
    Hardware: Microsoft Intellimouse Explorer 3.0
    Explorer Folder Option selected: Single-click to open an item (point to select); Underline icon titles only when I point on them
    Display: Detail list (Ctrl + Shift + 6)
    No touch input
    Here's the problem: For as long as I have used windows, I can select multiple files by pressing ctrl-left mouse button. If I want to select multiple consecutive files, I move my cursor down to the last file in the list and press shift-left mouse button.
    If I want to select multiple files that are not listed consecutively, I move my cursor along the list of files and press ctrl-left mouse button to select each individual file.
    This does not work for me any longer and I do not know why.
    Often I will press ctrl-left mouse click and the file will not select. When I move my mouse away from the file I've selected, it will UN-select. If I continue to press the CTRL key while attempting to select another file and float my mouse cursor down the
    list of files to select ONE single file further in the list, ALL the files in between the first file I click and the final file will become selected.
    Moving the mouse cursor carefully and steadily to select individual files yields varied results; sometimes I can select individual files; sometimes, I can click multiple times to select an additional file and the file will not become selected. More often
    than not, I will select several files and earlier files will become unselected.
    Extremely frustrating.
    I have been a Windows user since version 3.1 and this has never happened to me. I have been a Windows 8.1 user for over a year now and this is a new wrinkle. I have done system restore multiple times and it has not solved the problem. I have uninstalled
    Intellipoint/Microsoft Keyboard & Mouse center and reinstalled and the problem has not solved. I have checked every setting for my mouse in the mouse center and cannot see a setting that imposes this feature.
    Changing folder options to Double-click to open an item (single click to select) solves the problem. I am able to navigate and organize my files the way I always have. Only happens when single-click feature is enabled. Please note: I have been using the
    single-click select feature since Windows XP.
    Your guidance and actual solution to this irritant is appreciated.

    Hi,
    During my test, I cannot repro this issue even I configure the same setting with you. Maybe a hardware issue or software issue.
    Does this issue happen to other mouse?
    Can you test in safe mode to check how it works?
    Alex Zhao
    TechNet Community Support

  • FileDialog - select multiple files

    I want to know if there is a way to extend the FileDialog class
    so it can allow multiple files to be selected, and return multiple
    files back in an array. I currently use it to return a single file:
    FileDialog fd = new FileDialog(f, title, FileDialog.LOAD);
    fd.setFile(fileType);
    fd.setDirectory(defDir);
    fd.setLocation(50, 50);
    fd.show();
    if (fd.getFile() != null)
    return fd.getDirectory() + fd.getFile();
    else
    return null;
    How can I extend it to return multiple files?
    Thanks,
    Steve

    The API documentation for that class says this:
    "The FileDialog class displays a dialog window from which the user can select a file."
    Note the next-to-last word in that statement.

  • Flash Player on Android, select multiple files

    We have a web app that uses a flash uploader and it works on Android phones and tablets but it will not let us select multiple files on these devices. Is this possible or is there a trick to get these devices to allow us to select more than one file at a time?
    Thank you,
    Keith

    Flash Player for Android is no longer available. For more information, see here:
    http://blogs.adobe.com/flashplayer/2012/06/flash-player-and-android-up date.html
    Android users can still download and install Flash Player from the Archived Flash Player Versions page on the Adobe website.
    Please refer : http://forums.adobe.com/thread/1061194
    Please see this page for a list of all certified devices:Flash Player Certified Devices

  • Is there a way to select multiple files and initiate the Capitalize function?

    I have hundreds of files all in upper case that are driving me crazy. I can select them one at a time, right click and then select Transformations/Capitalize. Is there a way to select multiple files and initiate the Capitalize function?

    You could use Automator to do this - take a look at the article at http://www.wikihow.com/Batch-Rename-Files-in-Mac-OS-X-Using-Automator to see how this might be done.
    Good luck...

Maybe you are looking for

  • Authorization to generate a report

    Dear all, In our environment, different Zenworks administrators have their permission to manage devices on the folder in device zone. How can I setup an authorization right for them to generate the limited report?? (only the device in the specify fol

  • InDesign exporting to PDF - .eps and .ai color issue

    I've been reviewing a lot of help forums and have played with a lot of solutions and can't seem to fix this one. With no updates or changes to my usual settings I've noticed an issue with my company logo when I export to PDF from InDesign CS6. Once I

  • HOW DO I DOWNLOAD NEW VERSION OF ADOBE FLASH PLAYER

    To Whom It May Concern:         I need to download a new version of Adobe Flash Player,but am having difficulty in doing so. Can someone please help me with this matter?

  • RSP- Fail to connect SAP Portal

    Good morning... Hopefully you can help me.... I need to download new tasks from RSP task: System task to retrieve tasks, but I can't do it, cause it shows me : Fail to retrieve tasks on back-end. I don't know what does it means... I checked and had t

  • Updating UI from mainmethod of NSthread

    I want to perform a heavy task in a worker thread, so I have started an NSThread. However, i want to periodically update the UI from the worker thread. Currently I am directly accessing the UI objects like NSTextField * and updating the text from the