Skip to main content
Participant
November 1, 2013
Answered

How can I batch a huge bunch of wmf to ai in multiple subfolders?

  • November 1, 2013
  • 3 replies
  • 3905 views

Hi,

I have a couple of thousand old cliparts in .wmf format that I have to convert to .ai.  What I need to do is simply open the .wmf, store it as .ai in exactly the same location.

Actions didn´t work because the files are in mutliple folders and subfolders. "Actions" keeped saving all the ai-files in the same folder. Which is kinda weird since this doesn´t happen when using the same action in PS.

Sure, there are some quality issues with converting wmf to ai - but for what we´re plannning the quality is sufficient.

CarlosCantos script at http://forums.adobe.com/message/5378444#5378444  looked like the thing to do. Loaded it in apple script,  patched the lines to open .wmf  and saved it in the Illustrator script folder, but all I got was a bunch of error messages, so I´m pretty clueless 😕😕 guess I´m not a script guy...

Any help is greatly appreciated

HF

This topic has been closed for replies.
Correct answer Larry G. Schneider

It's likely it was an ExtendScript (the Adobe version of Java). Just looked and I'm right.

From Applications/Utilities/Adobe Utilities folder open the ExtendScript application, do a File>New and paste the copied text. Save with a .jsx file extension. Place it in Applications/Adobe Illustrator CSX/Presets/en_US/Scripts and restart AI.

// script.name = makeAiFilesPDFcompatible.jsx;

// script.description = opens and resaves Ai files with PDF compatibility checked (Folder Batch);

// script.requirements = none

// script.parent = CarlosCanto // 06/4/2013;

// script.elegant = false;

// script.forumPost = http://forums.adobe.com/thread/1224874?tstart=0

var folder = Folder.selectDialog("Select Source Folder..."); // select folder

if (folder==null) {

                    alert("Good Bye");

}

else {

    var files = find_files (folder, ['.wmf']);

          var fileCount = files.length; // count them

          if (fileCount>0) {

                    for (i=0; i<fileCount; i++) {

            var idoc = app.open(files);

            var saveOpts = new IllustratorSaveOptions();

            saveOpts.pdfCompatible = true;

            idoc.saveAs( files, saveOpts );

            idoc.close();

                    }

        alert(fileCount + ' file(s) processed');

          }

          else {

                    alert("There are no Illustrator files in this folder.");

          }

}

// recurse subfolders - Peter Kharel

function find_files (dir, mask_array){

    var arr = [];

    for (var i = 0; i < mask_array.length; i++){

        arr = arr.concat (find_files_sub (dir, [], mask_array.toUpperCase()));

    }

    return arr;

}

function find_files_sub (dir, array, mask){

    var f = Folder (dir).getFiles ( '*.*' );

    for (var i = 0; i < f.length; i++){

        if (f instanceof Folder){

            find_files_sub (f, array, mask);

        } else if (f.name.substr (-mask.length).toUpperCase() == mask){

            array.push (f);

        }

    }

    return array;

}

I just tried this with some .emf files (since I didn't have any .wmf handy) and it worked fine.

3 replies

Participating Frequently
January 5, 2024

I am interested, but for Adobe Illustrator 2024, the script no longer work, anyone can help to advise?? Many thanks

CarlosCanto
Community Expert
Community Expert
January 5, 2024

there are many scripts in this thread, which one you're referring to?

Participating Frequently
January 5, 2024

i basically try every single one. no luck

Participant
October 6, 2015

So, this is a super old thread, but it came up in google almost at the top for what I was looking for, and it put me on the right track immediately, so I'm going to post the script I cobbled together that got all this done.

I have like... 10,000 wmf files? Somewhere in that range. These suck and you can't preview them in finder, so no one thinks to go through them (opening 1 by one), so this time when I was charged with finding some clipart, I decided to see if I could find a way to convert them all to .ai so finder can give me neat little previews.

Larry's script worked perfectly, but then, like OP, I was left unsatisfied by the artboard's size. Carlos knew exactly what he was wanting and artboardRect was definitely the way to go, but he didn't spell out how to use it. So I went to hunting again.

Knowing no extendscript and my js skills limited to query, I somehow managed to cobble together a working script by adding in the 1 and only answer from this stack overflow post. And so here it is. Enjoy! If it breaks, I honestly can't help...

(additions in bold, comments from stack overflow user)

// script.name = makeAiFilesPDFcompatible.jsx;

// script.description = opens and resaves Ai files with PDF compatibility checked (Folder Batch);

// script.requirements = none

// script.parent = CarlosCanto // 06/4/2013;

// script.elegant = false;

// script.forumPost = http://forums.adobe.com/thread/1224874?tstart=0

var folder = Folder.selectDialog("Select Source Folder..."); // select folder

if (folder==null) {

                    alert("Good Bye");

}

else {

    var files = find_files (folder, ['.wmf']);

          var fileCount = files.length; // count them

          if (fileCount>0) {

                    for (i=0; i<fileCount; i++) {

            var idoc = app.open(files);

            var doc = app.activeDocument; 

            // Select all objects on the artboard

            doc.selectObjectsOnActiveArtboard();

            // Get the size of the art

            doc.artboards[0].artboardRect = [0, doc.selection[0].height, doc.selection[0].width, 0];

            // Get the active Artboard index

            var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];

            var artboardBottom = activeAB.artboardRect[3];

            activeAB.position = (doc.selection[0].position[0], doc.selection[0].position[1]); 


            // Get the active Artboard index

            var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];

            // Get the Height of the Artboard

            var artboardBottom = activeAB.artboardRect[3];

            // The page item you want to move. Reference it how you will. This just

            // obviously grabs the first pageItem in the document.

            var myPageItem = doc.pageItems[0];

            // Here is where the magic happens. Set the poition of the item.

            // [0,0] would be at the top left, so we have to compensate for the artboard

            // height. We add myPageItem's height for offset, or we'd end up BELOW

            // the artboard.

            myPageItem.position = [0, artboardBottom + myPageItem.height];

           

            var saveOpts = new IllustratorSaveOptions();

            saveOpts.pdfCompatible = true;

            idoc.saveAs( files, saveOpts );

            idoc.close();

                    }

        alert(fileCount + ' file(s) processed');

          }

          else {

                    alert("There are no Illustrator files in this folder.");

          }

}

// recurse subfolders - Peter Kharel

function find_files (dir, mask_array){

    var arr = [];

    for (var i = 0; i < mask_array.length; i++){

        arr = arr.concat (find_files_sub (dir, [], mask_array.toUpperCase()));

    }

    return arr;

}

function find_files_sub (dir, array, mask){

    var f = Folder (dir).getFiles ( '*.*' );

    for (var i = 0; i < f.length; i++){

        if (f instanceof Folder){

            find_files_sub (f, array, mask);

        } else if (f.name.substr (-mask.length).toUpperCase() == mask){

            array.push (f);

        }

    }

    return array;

}

Larry G. Schneider
Community Expert
Larry G. SchneiderCommunity ExpertCorrect answer
Community Expert
November 1, 2013

It's likely it was an ExtendScript (the Adobe version of Java). Just looked and I'm right.

From Applications/Utilities/Adobe Utilities folder open the ExtendScript application, do a File>New and paste the copied text. Save with a .jsx file extension. Place it in Applications/Adobe Illustrator CSX/Presets/en_US/Scripts and restart AI.

// script.name = makeAiFilesPDFcompatible.jsx;

// script.description = opens and resaves Ai files with PDF compatibility checked (Folder Batch);

// script.requirements = none

// script.parent = CarlosCanto // 06/4/2013;

// script.elegant = false;

// script.forumPost = http://forums.adobe.com/thread/1224874?tstart=0

var folder = Folder.selectDialog("Select Source Folder..."); // select folder

if (folder==null) {

                    alert("Good Bye");

}

else {

    var files = find_files (folder, ['.wmf']);

          var fileCount = files.length; // count them

          if (fileCount>0) {

                    for (i=0; i<fileCount; i++) {

            var idoc = app.open(files);

            var saveOpts = new IllustratorSaveOptions();

            saveOpts.pdfCompatible = true;

            idoc.saveAs( files, saveOpts );

            idoc.close();

                    }

        alert(fileCount + ' file(s) processed');

          }

          else {

                    alert("There are no Illustrator files in this folder.");

          }

}

// recurse subfolders - Peter Kharel

function find_files (dir, mask_array){

    var arr = [];

    for (var i = 0; i < mask_array.length; i++){

        arr = arr.concat (find_files_sub (dir, [], mask_array.toUpperCase()));

    }

    return arr;

}

function find_files_sub (dir, array, mask){

    var f = Folder (dir).getFiles ( '*.*' );

    for (var i = 0; i < f.length; i++){

        if (f instanceof Folder){

            find_files_sub (f, array, mask);

        } else if (f.name.substr (-mask.length).toUpperCase() == mask){

            array.push (f);

        }

    }

    return array;

}

I just tried this with some .emf files (since I didn't have any .wmf handy) and it worked fine.

HF23Author
Participant
November 2, 2013

Hi Larry,

1000 kudos! :-) Works like a charm. Many many thanks! You realy helped me a lot!