Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi Larry,
1000 kudos! š Works like a charm. Many many thanks! You realy helped me a lot!
Copy link to clipboard
Copied
Hi Larry,
is there any way to include "crop to artworks bound" In this script?
I fiddled around with ArtClippingOption.OUTPUTARTBOUNDS but somehow I donĀ“t get how to do it right...
Thanks in advance š
HF
Copy link to clipboard
Copied
this script only has options as if you do SaveAs... in the user interface, artClipping is an ExportOptionsFlash only.
Copy link to clipboard
Copied
But if the OP is using CS6 or CC he could use an action to use the menu item Object>Artboards>Fit to Artwork Bounds.
Copy link to clipboard
Copied
correct, I was trying to say that "fit to artwork bounds" is not an option of the IllustratorSaveOptions() object, regardless of Ai version one could resize the artboard to fit the art, before saving.
Copy link to clipboard
Copied
I`m running OSX 10.9 and CS5. So I guess that means I canĀ“t include "clip to artwork bounds" in the script? Strange I was pretty sure this is possible. But I donĀ“t know s.... about scripts.
Thanks a million anyway, you guys realy helped me
HF
Copy link to clipboard
Copied
You can by setting up an Action in AI and then using the doScript call to perform that action (available in CS6 and above in ExtendScript and in earlier versions in AppleScript and VisualBasic)
Copy link to clipboard
Copied
Ah Ok.
So out of curiosity I created a new actionset called "Crop" and a new action called "CropToArt". Next inserted the line
var doScript (action: CropToArt, from: Crop, dialogs: bool=false);
at this point (marked fat) in the script. DidnĀ“t work though. I deleted "var", toggled bool to false and true = zippo. Is it because IĀ“m running CS5? Or do I have to create a Javascript (how do I do that...?)
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 doScript (action: CropToArt, from: Crop, dialogs: bool=false);
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.");
}
}
Thanks guys
HF
Copy link to clipboard
Copied
yes, doScript was introduced in CS6...check artboardRect property in the documentation, that will let you change the artboard bounds to your needs.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
I am interested, but for Adobe Illustrator 2024, the script no longer work, anyone can help to advise?? Many thanks
Copy link to clipboard
Copied
there are many scripts in this thread, which one you're referring to?
Copy link to clipboard
Copied
i basically try every single one. no luck