Illustrator Scripting :: Why Won't Script Work On All Files In Folder
Jun 13, 2013
It is supposed to change hyphens to en-dashes in a ai files in a folder. However, when I run it, it only works on one file. After it makes the change and closes the first file, it stops.
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts;
sourceFolder = Folder.selectDialog;
if ( sourceFolder != null )
{
files = new Array();
fileType = "*.ai";
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )
[code]....
I created an Action to batch export a folder of .ai files to create 300dpi .png's of the .ai file's artboard. I did this by simply recording "Export...as png" with my desired settings then Batch running the Action on desired folder of .ai files. The files were successfully exported, the trouble is that the exported files lack a .png file extension. My intent is to take these PNG files and merge them into a single PDF using Acrobat Pro. Unfortunatly, without the .PNG extension, Acrobat Pro does not recognize the file types and does not let me use the Combine Files feature on them. Going back and manually adding a .png at the end of the exported files defeats the time-saving purpose of Batch Processing all together. Is there something I am missing or doing incorrectly? I have included screenshots of 1) My Batch Action settings 2) folders showing files without .png extension and 3) visual of what I see when I am trying to combine PNGs into a PDF.
Any way to allow a user to choose a folder from a default location. I thought I had found the solution but it's not quite working as I wanted:
#target illustrator
//Example 1 var output_folder = Folder.selectDialog ('Choose PDF output folder.');
//Example 2 var myFolder=Folder(app.activeDocument.path).selectDlg("Choose PDF output folder:");
If I use the code in example 1 the choose folder dialog appears and the 'Open' button is available and when I press the button the location is chosen as expected. However if I use the code in example 2, although the choose window opens in the path of the active documents location the 'Open' button is not able to be pressed until I select a folder., which means that the chosen location is not correct. I should indicate that I'm running this code on a Mac.
Any way to have a choose folder dialog window specify a location and be able to select that.
I have some +900 legacy pdf's that need to have a title and date change. The pdf's where generated in ArcMAP 10 so the text appears as individual letters. So I wrote a script that creates a knockout and adds the required text. I can get this to work for an individual file but I can't figure out is how to have the script perform it for all the pdf's in a folder.
Set appRef = CreateObject("Illustrator.Application") Set docRef = appRef.Open("C:WorkCity_Wide_Zoning�_Spring_2013TestA001.pdf") ' ************************* 'Knockout
I'm using Illustrator for work and I love it, I never needed scripts yet. Now I have couple houndred svgs coming in per day, I would like to have a script that opens every svg one by one in the selected directory and add them to a pdf as pages of the same size and than save it.
How do I set a folder as a relative path to where the script is running?
is there any easy way like in unix, starting without / ?or for example
"~/Desktop/"
"/users/<login>/desktop/"
seems that path to me is the only way...
is there an easy way to change posix paths to applescript??
I have this code:
tell application "Finder" to set templateFile to (container of (path to me) as string) & "Graficas FINAL ADQAT.ai"
with this error: error "No se ha encontrado el archivo Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai." number -43 from "Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai"
the file is there how I change the filepath to be compatible with applescript?
I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:
var w = new Window ("dialog"); var f = new File ('~/Desktop/transparencyGrid.jpg'); w.add ("image", undefined, f); w.show ();
However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:
var w = new Window ("dialog"); var f = new File ('../../../transparencyGrid.jpg'); w.add ("image", undefined, f); w.show ();
But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.I say that because when I do this:
alert(Folder.current);
The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.
So, is there a way of setting Folder.current to the location of the actual script?
My main user folder on the iMac is set to be shared (read/write, including all enclosed files) with my MacBook Pro. The job is a series of one-page InDesign files (they are newspaper advertisements). The IDD files contain a series of Illustrator files with linked PSD files.The idea is that we can both work on the .idd and .ai files in the same folder at the same time.
It's all working fine EXCEPT that whenever an .ai file is opened on the MacBook, Illustrator doesn't know where the linked PSD files are. We can update the link, but when the .ai file is then opened on the iMac and saved, the same thing happens the next time it is opened on the Macbook.
I don't want to embed the PSD files into the .ai files as sometimes I have to modify them and they can be linked to up to 20 .ai files.
G5 iMac OSX 10.7.5 / Macbook Pro OSX 10.8.2 / networked via FireWire cable / file sharing on, laptop user has Administrator status, all files are read/write, permissions include all enclosed files / CS6
I'm using Illustrator CS6. I have an artboard with 200 of the same placed file. I now want to use this same layout for 30 other views, they are the same size, but different images. If I relink them I have to click through each one. I tried using a script I found on here by Carlos:
#target Illustrator // script.name = relinkAllSelected.jsx; // script.description = relinks all selected placed images at once; // script.required = select at least one linked image before running; // script.parent = CarlosCanto // 7/12/11; // script.elegant = false;
I'm on a mac, os x 10.6.8. and I copied the script into the script preset folder so its starting from the drop down menu. Don't think I'm leaving anything out. I'm swapping 1 placed(linked) PDF for another.
There is no way to export PNG-files with a higher PPI than 72. I saw a thread that you could scale the pictures when exporting then script to open Photoshop and resize them? This is the last step in my big script and if i cant get this to work i cant use it.
I found a script that does the job, export tones of ai files to pdf, but I have some files which are in sub folders, and I was trying to find a way to modify this script to include subfolder, but no luck.
Adobe permits you to use, modify, and distribute this file in accordance with the termsof the Adobe license agreement accompanying it. if you have received this file from a source other than Adobe, then your use, modification,or distribution of it requires the prior written permission of Adobe.
This sample gets files specified by the user from the selected folder and batch processes them and saves them as PDFs.
Edits by Patrick Mineault: - only .ai files processed - files saved in same folder as the input files - export files have name (oldname).pdf - PDF settings: editable / acrobatLayers=true for maximum compatibility with Preview
// Main Code [Execution of script begins here] // uncomment to suppress Illustrator warning dialogs // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts; // Select the source folder. sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator .ai files you want to convert to PDF'); [code]...
Is there a way to open a file as a layer? I want to open multiple files in the same window to make a collage. Currently, as I open each file they all open in separate windows. The "Open Document As Tabs" option in the User Interface preferences is not selected.
I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?
What would be the best strategy on the usage of data set to translate our product packaging. It's quite complex as we have several languages on the same packaging. Moreover, we have different text sources that would require to be translated in different sets of languages.
I have already looked into the data set and I tried to get familiar with it. How to create the data set and how to name the different variables knowing that there are different source texts for a particular region (region means a set of languages) and other texts for another region... The idea is to export this into one XML file with well identified elements that can be split with a tool, sent for translation according to their region then merged back into one single file to be imported back into illustrator
Region 1: en-US text 1 text 2
fr-FR text 1 text 2
de-DE etc...
Region 2: en-US text 3 text 4
ru-RU text 3 text 4
Region 3: etc..
It seems that the formatting such as bold, italic and so on is not exported into the data set which is quite embarrassing.
I recently found the following jsx script, which saves a multi-layered IL file into 1-layer-per-file with PNG format.
This file is very useful, but i'm currently working on a project that requires the files to be saved into SVG format.
Is there anyway to edit this script to save the files as SVG instead of PNG?
// *** Export Layers as PNG files (in multiple resolutions) *** // // Version: 1.0 (29 Aug 2012) // Copyright Arcticmill 2012 // www.arcticmill.com // Developed by: Johan Otterud // // This script will export all layers that have a name starting with "#", or "%" into a subfolder of the current .ai document. // These options can be configured below: // *** Config options *** var subFolderName = "Export";
[Code]...
Remember that you must add a "" + exportLayersStartingWith + "" (when exporting the layer cropped to it's bound) or "" + exportLayersWithArtboardClippingStartingWith + "" (when layer should be clipped to artboard) to the beginning of the layer name. Also make sure that they layers you want to export are not locked or hidden.");
} else { // Show a completed message alert(layersToExportCount + " layer(s) was successfully exported to: " + exportDirectoryPath); }
I have about 300+ product labels that are in Illustrator, and some of them have an incorrect rich black color swatch. What I have been doing is going through and changing the color pallette to change them manually. Essentially going to the instance of black and changing them to regular black.
Is there any sort of script that can do this? The files are in CMYK.
Otherwise I have a lot of monotonous file editing to do.
I need to find a way to convert a LOT of ai files, individually, to low res pdf's. Preferably with the presets I want, not some defaults. I'm not interested in an action. I was hoping for a droplet, script, or something similar.
I did find this and it looked promising... [URL] ....
That almost worked. Ultimately, for some reason, it couldn't see the ai files sitting in the specified folder.
Is it possible to have a script that would split up an Illustrator file that contains a number of groups of elements into individual files... for example, here is a download link for a file that has different types of moustaches and I want each moustache as an individual file... I have hundreds of Illustrator files like this that have 4, 8, 15, 20 or more illustrations all bunched onto the one file that I need to split up. I'm using CS4 [URL]....
I have a couple thousand AI authored EPS files with a specific swatch name (SpotBlack) that I would like to rename (black) -- is there any method to do this en masse, preferrably outside of Illy using a text editor?
I have 30 separate illustrator pdf files (one page each) that I would like to make into one Illustrator CS6 file with 30 artboards. Is there any way to do that without having to import one by one?
I have about 500 files that I need to change one line of text in. Example. File name is XXX 001, the line of text is the file name so it would read XXX 001. XXX 002... etc. up to XXX 500. Is there a way that I could automate it opening, changing this line of text, saving and closing?
I accidently saved files to the "swatches" folder in AI CS5. Now I can retrieve them OR see them when I look in finder. I've used the finder search and nothing. I'm running on a Mac.
Automated AI so much so that it can read instructions from an external source like xml or txt and automatically creates files and folders.
For example we have something like this: File1 Hello Font: Myriad Size: 22 Colour: Pantone 254C Image 1.jpg (link) Source: Image1.png (link) clipart1.eps (link) ---------- File2
and so on.
I want AI CS5 to: 1. create an eps File1, create a folder named File1, put File1.eps in it 2. type the text Hello, apply Myriad 22pt and PMS 254 to it, centre it to the artboard 3. Place all jpegs, pngs, eps source files on the artboard and embed them. 4. Save the file as eps legacy version 10, close the file and move to the next file.
I've written a script to allow you to select an image to replace any number of selected files. Each file starts out as an embeded image with a .note to determine where the basis of alignment for the new file should be (i.e. "top," "bottom," "left," "right"). You'll find the code below:
#target illustrator
if (app.documents.length > 0) { var docRef=app.activeDocument; var docSelection = docRef.selection; // ** Get new file
[Code]...
For some reason, the ".note" added at the end of the script gets erased once the script is complete. I can even get it to confirm that it applied the note to the image, but once it's complete, it's gone.
I created a action in Illustrator CS6 (on a PC) which opens PNG files, scales them onto a 8.5 x 11 page, saves them as a PDF into a output folder on my desktop and then closes the page. The action works great and does exactly what I had hoped for.
Here is my issue: I now have a need to do this on multiple files at the same time. Using the Illustrator Help menu, I found out about Batch processing. The tutorial says that a batch can be run on a single file or on a folder of files. Bingo! That's what I want. Problem is, I can't get it to work.
After setting up the batch with the following settings: (note: I didn't use a destination folder because I have the action saving the pdf into an output folder on the desktop).
According to the help page, it said to use Override Action "Open" commands which Opens the files from the specified folder and ignores any Open commands recorded as part of the original action. I thought this is what I needed to open all the files in the folder, because when recording my action, I had to use the open command to open a png file. It wouldn't just let me choose a folder. If I don't have the open command in the action, nothing happens.
My main issue is getting multiple files from within my input folder to open when running the action. The only file that opens is the file that I recorded while creating the action. If I remove that file from the folder, nothing happens at all.