Trying to modify SaveDocsAsSVG to open and save all files within a directory automatically

I am trying to do as the title suggests, but I can't find a way to specify the folder I want the script to look at and I can't get it to open/save/close the files without user interaction. Another way to say it is that I need this to be itterative as the PC I'm using cannot handle too many open files at once.
On a side note, I can't even find the documentation. Example, what arguments does Folder.selectDialog() accept? Where is the documentation for that?
Thank peeps!
Using CS6 trying to convert EPS to SVG

Here is what I have so far. I think I'm close I just need to figure out how to open the documents in the app and close them after converting them so only one document is open at a time. My goal is to run this program over night since there are thousands of files to convert. Thank you all for your help!
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
try {
          if (app.documents.length > 0 ) {
                    // Get the folder to save the files into
        var inFolder = Folder( Folder.desktop + '/temp' )
        var files = inFolder.getFiles( /\.eps$/i );
                    var destFolder = null;
                    destFolder = '~/Desktop/temp';
                    if (destFolder != null) {
                              var options, i, sourceDoc, targetFile;
                        // Get the SVG options to be used.
                              options = this.getOptions();
                        // You can tune these by changing the code in the getOptions() function.
                              for ( i = 0; i < files.length; i++ ) {
                  //THIS IS WHAT I NEED HELP WITH
                  var docRef = open(files[i]);
                  sourceDoc = app.documents[i]; // returns the document object
                                        // Get the file to save the document as svg into
                                        targetFile = this.getTargetFile(sourceDoc.name, '.svg', destFolder);
                                        // Save as SVG
                                        sourceDoc.exportFile(targetFile, ExportType.SVG, options);
                                        // Note: the doc.exportFile function for SVG is actually a Save As
                                        // operation rather than an Export, that is, the document's name
                                        // in Illustrator will change to the result of this call.
                              alert( 'Documents saved as SVG' );
          else{
                    throw new Error('There are no document open!');
catch(e) {
          alert( e.message, "Script Alert", true);
/** Returns the options to be used for the generated files.
          @return ExportOptionsSVG object
function getOptions()
          // Create the required options object
          var options = new ExportOptionsSVG();
          // See ExportOptionsSVG in the JavaScript Reference for available options
          // Set the options you want below:
          // For example, uncomment to set the compatibility of the generated svg to SVG Tiny 1.1
          // options.DTD = SVGDTDVersion.SVGTINY1_1;
          // For example, uncomment to embed raster images
          // options.embedRasterImages = true;
          return options;
/** Returns the file to save or export the document into.
          @param docName the name of the document
          @param ext the extension the file extension to be applied
          @param destFolder the output folder
          @return File object
function getTargetFile(docName, ext, destFolder) {
          var newName = "";
          // if name has no dot (and hence no extension),
          // just append the extension
          if (docName.indexOf('.') < 0) {
                    newName = docName + ext;
          } else {
                    var dot = docName.lastIndexOf('.');
                    newName += docName.substring(0, dot);
                    newName += ext;
          // Create the file object to save to
          var myFile = new File( destFolder + '/' + newName );
          // Preflight access rights
          if (myFile.open("w")) {
                    myFile.close();
          else {
                    throw new Error('Access is denied');
          return myFile;

Similar Messages

  • Open and Save Excel Files

    Hi All,
    I need code of How to open and save excel file in local system in Oracle forms.
    With Regards,
    Chandra Shekhar

    Hello Chandra,
    Webutil can be used to achieve this functionality.
    STEPS TO FOLLOW
    ================
    1. Install and configure Webutil following instructions in the webutil manual
    and the readme file.
    2. Create a form with a block Eg. DEPT
    3. Create a button, and in that button put the following code -
    DECLARE
    application Client_OLE2.Obj_Type;
    workbooks Client_OLE2.Obj_Type;
    workbook Client_OLE2.Obj_Type;
    worksheets Client_OLE2.Obj_Type;
    worksheet Client_OLE2.Obj_Type;
    args Client_OLE2.List_Type;
    cell ole2.Obj_Type;
    j INTEGER;
    k INTEGER;
    BEGIN
    application := Client_OLE2.create_obj('Excel.Application');
    workbooks := Client_OLE2.Get_Obj_Property(application, 'Workbooks');
    workbook := Client_OLE2.Invoke_Obj(workbooks, 'Add');
    worksheets := Client_OLE2.Get_Obj_Property(workbook, 'Worksheets');
    worksheet := Client_OLE2.Invoke_Obj(worksheets, 'Add');
    go_block('dept');
    first_record;
    j:=1;
    k:=1;
    while :system.last_record = 'FALSE'
    loop
    for k in 1..3 /* DEPT has 3 columns */
    loop
    If not name_in(:system.cursor_item) is NULL Then
    args:=Client_OLE2.create_arglist;
    Client_OLE2.add_arg(args, j);
    Client_OLE2.add_arg(args, k);
    cell:=Client_OLE2.get_obj_property(worksheet, 'Cells', args);
    Client_OLE2.destroy_arglist(args);
    Client_OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
    Client_OLE2.release_obj(cell);
    End If;
    next_item;
    end loop;
    j:=j+1;
    next_record;
    end loop;
    /* For the last record */
    for k in 1..3
    loop
    If not name_in(:system.cursor_item) is NULL Then
    args:=Client_OLE2.create_arglist;
    Client_OLE2.add_arg(args, j);
    Client_OLE2.add_arg(args, k);
    cell:=Client_OLE2.get_obj_property(worksheet, 'Cells', args);
    Client_OLE2.destroy_arglist(args);
    Client_OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
    Client_OLE2.release_obj(cell);
    End If;
    next_item;
    end loop;
    Client_OLE2.Release_Obj(worksheet);
    Client_OLE2.Release_Obj(worksheets);
    /* Save the Excel file created */
    args := Client_OLE2.Create_Arglist;
    Client_OLE2.Add_Arg(args,'d:\test.xls');
    Client_OLE2.Invoke(workbook, 'SaveAs', args);
    Client_OLE2.Destroy_Arglist(args);
    /* release workbook */
    Client_OLE2.Release_Obj(workbook);
    Client_OLE2.Release_Obj(workbooks);
    /* Release application */
    Client_OLE2.Invoke(application, 'Quit');
    Client_OLE2.Release_Obj(application);
    END;
    4. Save the form and compile it.
    5. Run the form.
    6. Execute the query in the block.
    7. Click on the button.
    8. An excel file will be created in the d:\ directory by the name test.xls.
    Kind regards,
    Alex
    If someone's answer is helpful or correct please mark it accordingly.

  • Illustrator Crashing on open and save of files

    PC using Windows 8
    I've been using Illustrator CC for 6 months and it worked fine, all of a sudden it can't open or save files without taking very long (5-10 minutes) and occasionally crashes.
    Please help!

    Then the best bet is to uninstall, run the cleaner tool and reinstall.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6

  • Open and Save downloaded files at the same time (in one click)

    OVERALL GOAL: To click on PDF links online, save the files to my Downloads folder, AND open them in Acrobat Pro, all in one click.
    Does anyone have a suggestion for how I would tell Firefox to both Save and Open my downloads? I'm using OS X, if it helps/matters.

    That happens automatically with both my Macs. I have one using 10.4 and another using 10.6. I use PDFView rather than Adobe, but I doubt that makes much difference. You are using Adobe as a helper application, not a plugin, right?

  • Action to open and save multiple files in a different format

    Photoshop CS5
    TCS 3
    I haven't used actions before.
    I want and to open all files in a folder of one format and save them to a different format.
    How is this done?
    Thanks
    Rob

    Assuming you have all one format and would like to just open all the files and save as a different format without changing anything...
    One way, using Photoshop and actions and automation, would be to define an action that just does a File - Open then File - Save As to a different file.
    To define an action, in the ACTIONS panel create a new set and a new action, then just record the steps on an existing file. Once done, hit the Stop button.
    Once this very simple action has been defined, use File - Automate - Batch... to set up to run the action on a whole folder full of files.
    You'll likely want to use the [ ] Override Action "Open" Commands and [ ] Override Action "Save As" Commands options.  The latter option allows you to do things like specify the JPEG save quality in the action, and not be prompted for it every time.
    Your Batch dialog may look something like this:
    -Noel

  • How to open and read many files from a directory and store contents in 2D array?

    I want to make a VI that opens and reads the data from various files contained in a directory (200 files each with 2 columns) and store these in a single 2D array. For file number 1 I want to store the data from both columns in the 2D array, but for files 2 to 200 I only want to store the second column of each file. Can someone please help?

    Hi Nadav,
    Thanks for your help. I have followed your instructions but i cannot get it to work. I used the LIST DIRECTORY to list the files in the directory - that works. However, how do I read each of the 200 files using READ FROM SPREADSHEET FILE without me having to manually select each of the 200 files? So, if I use LIST DIRECTORY to list all 200 files in an array, how do I get each of these to open and store the data in a 2D array? Here is what I have done (File called read_files.VI) Could you please help me? Thank you very much in advance.
    Attachments:
    read_files.vi ‏18 KB

  • HTML  Parsers and reading all files in a directory

    Hello all,
    I was wondering if there was a html parser included in java. I am writing a program where I want to be able to search all the files in a directory tree for a particular string. I was able to read one file in a single directory but not in any other directory. How would I go about writing code to be able to access all files in directory that has multiple sub folders.
    Also, when I started to write my program I tried to use the DOM XML Parser to parse my html page. My logic behind this decision was that if you look at html code it is an xml document. But as I was trying to run my program I noticed that I had to convert my html document into xml format. I really don't want to have to build my own html parser. Is there a html parser that is included in Java. Oh my program is just your basic text program. No interfaces.
    Thanks for any help that you can provide
    Hockeyfan

    a particular string. I was able to read one file in
    a single directory but not in any other directory.
    How would I go about writing code to be able to
    access all files in directory that has multiple sub
    folders.
    You can do that several ways.
    Most likely you'll end up with some sort of recursive iteration over the directory tree.
    Not hard to write, somewhat harder to prevent memory problems if you end up with a lot of data.
    Also, when I started to write my program I tried to
    use the DOM XML Parser to parse my html page. My
    logic behind this decision was that if you look at
    html code it is an xml document. But as I was
    trying to run my program I noticed that I had to
    convert my html document into xml format. I really
    don't want to have to build my own html parser. Is
    there a html parser that is included in Java. Oh my
    program is just your basic text program. No
    interfaces.
    A VALID xhtml document is a valid XML document.
    Problem is that most HTML isn't xhtml.
    Another problem is that most HTML is fundamentally broken even to its own standards (which have always been based on SGML on which XML is also based).
    Browsers take that into account by being extremely lax on standards compliance and effectively making up tags as they go along to fill in the missing ones in the trees they parse.
    That's however not a standardised process and each browser handles it differently (and as a result most html will render differently in different browsers).
    Java contains a simple HTML parser in Swing, but it's primitive and will only parse a subset of HTML 2.0.
    There are almost certainly 3rd party libraries out there that can do better, both free and/or commercial.

  • Is it possible to select all files within a directory (and not the folders/subfolders)?

    For instance, in my iTunes directory, I would like to select all of the music files without selecting the other olders (artist name, album name). Going through with Shift+click and command+click will take an eternity. If I just highlight everything and hit "open", it will open ALL of the folders as well as opening the actual files. I want to skip the folders if possible with a mass selection.

    Well, its gonna be an expensive comparison since there is no non-arbitrary way to iterate through the files, but try:
    String f1, f2;  // the comparing files
    //get a primary list of files to iterate through
    Process p = Runtime.getRuntime.exec("ls");  // if in Linux
    BufferedReader pri =
        new BufferedReader(
        new InputStreamReader(
        p.getInputStream()));
    while((f1 = pri.readLine()) != null){    // for each file...
        Process q = Runtime.getRuntime.exec("ls");  // get all file names
        BufferedReader sec =
            new BufferedReader(
            new InputStreamReader(
            q.getInputStream()));
        while((f2 = sec.readLine()) != null){   // and for each of these
            if(!f1.equals(f2))  // as long as it's not the same file
                DO_COMPARISON(new File(f1), new File(f2));   // compare them
    }

  • How do you open and save PNG files as images rather than a document (which my MacBook is doing automatically)?

    Hi,
    Basically I'm doing a course in which i need to import images on a document for evidence (in particular Cirque Du Soleil, yes it's a weird course!) I am using the develop menu tab and using the Inspect Element menu. Here i have found loads of images that are perfect for my evidence, but the images are all showing as PNG files. Whenever I try to save these they will only save as Documents and not images. How can I change this so I can save them as images and import them imto Pages.
    Many Thanks
    Mason

    Hi @Shootist007
    I knew PNG files were image files, that why i was confused when I saved them onto my Mac they were showing as Documents under file type. But i managed to do via Preview (opened it up in Preview then click and dragged to my document).
    Thanks for your help

  • Why does Apple say that Numbers can open and save Excel files, when in actuality, it can only open .XLSX files and only Export to Excel (not save-as excel)?

    When attempting to open .XLS files in Numbers, the format is not recognized. When the format is .XLSX, the format is recognized. Why is it this way? It's still much more common for folks to have the .XLS file format on their excel files. Why would Numbers not be backwards-compatible?
    Additionally, to state in the benefits of this program that one can save to 'Excel' is a little misleading. You can't save to anything except .numbers. Sure, you can export to Excel (with file extension .XLS, I might add), but you can't save or save-as.
    Does anyone else see the irony in being able to export to .XLS but not be able to open an .XLS?
    There is something to be said for clarity.
    You can't expect folks to have Numbers and Excel on their systems, so how else are they supposed to open .XLS files in Numbers?
    And I don't need to see another advertisement for NeoOffice or OpenOffice here, thanks. I'd actually like Numbers to be a little more sensible.
    That is all.

    When the advertisements were written, there was no Lion so we were able to Save As Excel.
    At thiqs time there is no longer Save As command under Lion but the feature is always available.
    When your editing task is ended, you are free to use this scheme:
    File > Duplicate
    File > Save and in the dialog you will have the option save as Excel.
    Numbers isn't and I hope that it will not become an Excel editor.
    Its resources contain a flag defining it this way.
    I posted several times a script editing this resource.
    This morning I'm not in a mood allowing me to do your duty.
    Search by yourself in existing threads with a keystring like
    viewer AND editor
    Yvan KOENIG (VALLAURIS, France) jeudi 27 octobre 2011 09:40:23
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Tags disappear when I open and save a file

    I've tagged some pdfs to help organize them in their folder. If I open one to edit it, the tag disappears as soon is the file is closed.
    Thus destroying the organization, as I've got the folder set to arrange by tabs.
    Is this a bug or somebody's idea of a feature? Any way to change this behavior?

    Well, you could just make your firewall behave and create an exception rule as the warning suggests... It's unlikely that this is PS itself, anyway. Eitehr it's a flakey driver or a cracked plug-in you may be using (not implying anything here, so keep cool) may produce a wrong hash value/ signature and trigger the alarm.
    Mylenium

  • Help! Can someone open and save a file in InDesign CS4 for me?? (idml to inx)

    I need one file as .inx ... I have it as .idml. Does someone have Adobe InDesign CS4, so that I could e-mail it and you could e-mail it back as .inx? I would really appreciate that

    I'm sending you an upload link by private message....

  • How open and see Log File in Active Directory

    Hello Friends..   ^-^
    how i can open log files active directory and see this data files ?
    Can export this logs ?
    thanks for help.

    And adds a definition of edbxxxxx.log for completeness:
    These are auxiliary transaction logs used to store changes if the main Edb.log file
    gets full before it can be flushed toNtds.dit.
    The xxxxx stands for a sequential number in hex. When the Edb.log file
    fills up, an Edbtemp.log file
    is opened. The original Edb.log file
    is renamed to Edb00001.log, and Edbtemp.log is
    renamed to Edb.log file,
    and the process starts over again. Excess log files are deleted after they have been committed. You may see more than one Edbxxxxx.log file
    if a busy domain controller has many updates pending.
    Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable. This helps the community, keeps the forums tidy, and recognises useful contributions. Thank you!

  • How to Open and Save files

    I have a problem to open and save the files.here is my code. can anyone help me to open the files.
    public void actionPerformed(ActionEvent e) {
    if ("open".equals(e.getActionCommand())) {
    FileDialog fdopen=new FileDialog(this, "Load File", FileDialog.LOAD);
    fdopen.show();
    Thanks for ur time

    Hi fbnmir or who ever can answer my question,
    My problem is similar to the code you wrote. I'm trying to make (or rather complete a half done) editor for text files. For opening and saving files I have so far:
    public void actionPerformed(ActionEvent ae){
    FileDialog filedialog;
    final SearchDialog searchDialog;
    String arg = (String)ae.getActionCommand();
    // the Open ... case
    if(arg.equals(Editor.fileLabels[0])){ 
    if(Editor.VERBOSE)
    System.err.println(Editor.fileLabels[0] +
                        " has been selected");
    filedialog = new FileDialog(editor, "Open File Dialog", FileDialog.LOAD);
    filedialog.show();
    if(Editor.VERBOSE){  
    System.err.println("Exited filedialog.setVisible(true);");
    System.err.println("Open file = " + filedialog.getFile());
    System.err.println("Open directory = " + filedialog.getDirectory());
    //the Save ... case
    if(arg.equals(Editor.fileLabels[1])){ 
    if(Editor.VERBOSE)
    System.err.println(Editor.fileLabels[1] + " has been selected");
    filedialog = new FileDialog(editor, "Save File Dialog", FileDialog.SAVE);
    filedialog.show();
    if(Editor.VERBOSE){ 
    System.err.println("Exited filedialog.setVisible(true);");
    System.err.println("Save file = " + filedialog.getFile());
    System.err.println("Save directory = " + filedialog.getDirectory());
    These are two components of a MenuHandler class. The problem with this code is that in the text editor window, even if the Open button is pressed the file I want to open isn't displayed. Although the System.err (I think that's what it is called) says:
    Open ... has been selected
    Exited filedialog.setVisible(true);
    Open file = tutorial_01.rtf
    Open directory = C:\dhruba\epgy_2006\tutorial\
    Save ... has been selected
    Exited filedialog.setVisible(true);
    Save file = test.txt
    Save directory = C:\dhruba\epgy_2006\tutorial\
    How can I actually display the file I want to open, or save some text I've written?
    I would appreciate any help, thanks.

  • Solution for Slow Open and Save As Dialogs under 10.4.4

    I don't know how many others out there may be experiencing this, but...
    I noticed that -- after updating to 10.4.4 -- I started getting really long delays when accessing Open and Save As file dialogs -- I mean, sometimes it would take 5 to 15 seconds for the dialog to appear!
    I did a lot of troubleshooting, and finally hit upon the solution a couple of nights ago:
    It's the Desktop iDisk!
    Going into the .Mac Preference Pane and turning off "iDisk Syncing" has totally eliminated the slowdown.
    I think it has something to do with DiskMirrorAgent, since that has frozen on me a couple of times and prevented logoff until I force-quit it.
    'Hope this helps.
    -- Steve
    Late 2005 DC G5 2.3 GHz, 4 GB RAM   Mac OS X (10.4.4)  

    Hi Matt,
    One can always manually mount the iDisk when needed, and it still syncs, albeit in real time, and kind of herky-jerky.
    As for the slowdown when multiple items are mounted, I believe I'm describing a different issue, related to DiskMirrorAgent. If and when you get this slowdown (with desktop iDisk syncing enabled), check Activity Monitor, and you'll see DiskMirrrorAgent sucking up most of the CPU time for the time it takes before the dialog appears. My record time was about 25 seconds.
    As for slow Open and Save As dialogs when multiple items are mounted: I customarily have several external FireWire drives mounted, and often a couple of CDs and/or DVDs (I produce a radio program, and have several optical drives), and I have had no Open or Save As dialog slowdowns since at least 10.3.x, maybe earlier.
    Even when the dialog opens to a directory on a CD that has spun down, the opening time on an Open or Save As dialog is nearly instantaneous for me, suggesting that Mac OS X 10.4.x is doing a good job of caching the data.
    But I hear you about the "old days," when it used to take forever to get a dialog to appear, just because a CD was mounted! Maddening!
    -- Steve
    Late 2005 DC G5 2.3 GHz, 4 GB RAM   Mac OS X (10.4.4)  

Maybe you are looking for