-
1. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 6, 2010 2:01 AM (in response to Chris Vreeland)Chris, you are NOT nuts this info can be got from either opening the file and reading thru the swatches/spots/inks collections then writing to text file. Or reading this info from the file's header info from:
%%DocumentCustomColors:
down to
%%CMYKCustomColor:
Between these should be the list of 'used in document' custom colors. You can check this by opening in any text editor app.
Do you have any more info on your files that may help? What OS are you on where are the files all in one folder? What format are they in?
If they were to be opened would it be just these colors in the swatches palette?
-
2. Re: Script to export swatch names as tab-delimited text?
userben Jan 6, 2010 1:43 PM (in response to Chris Vreeland)That seems like a relatively easy task, depending on your OS, scripting language, and Illustrator version.
You can of course write the list of names directly to a spreadsheet--you don't need to create an intermediate document. A script can interact with multiple applications.
Where are you at right now? Do you have some scripts you are currently writing? What language are they in?
-
3. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 11, 2010 7:04 AM (in response to userben)Thanks, both of you and sorry for the late reply --
I'm running CS3 on a PPC Mac, OS 10.5.8. I have no idea how to write any sort of script unless it's a GUI thing like Automator or recording an action, so I've done no scripting with this as of yet.
The only swatches in any of my final print files are the defaults that won't go away, (None, Black, White & Registration) and whatever swatches are actually used in the file -- generally pulled from the Pantone Solid Coated library, but always spot, even if they're custom.
I keep the files in separate directories, (/Art/Year/Month/Client/Design) so I don't think batching a directory would work -- I don't think I'd want to batch them anyway, since I keep the original client file for reference alongside my final print file. I'd be happy to extract this info one job at a time, as I have about 150 files total at this point I'd like to do this to, and a few months to do this project.
I guess what I'd like to come away with is either an action I could run when the file is open, or something like a droplet I could drop the file onto. I'm open to whatever approach seems to make the most sense, and am willing to dive in to learning some sort of scripting language if I can take this away as a tangible result of the project. It'll do me some good to learn, anyway.
Thanks!
-
4. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 11, 2010 7:14 AM (in response to Chris Vreeland)Chris, you could give this a try? It was done for mac OS as a batch. It should…(if it works) write a tab delimited text file to your desktop. As is it works for all the illustrator .ai & pdf files of a given folder. It would append the text file for each directory which you run it on. If it works this could easily be changed to work with just an open doc.
var defaultFolder = new Folder ('~/Desktop');
var illFolder = defaultFolder.selectDlg('Please select your Folder of Illustrator files…');
if (illFolder != null) {
var fileList = illFolder.getFiles(fileFiltering);
if (fileList.length > 0) {
main(fileList);
} else {
alert('This Folder contains NO Illustrator files!');
}
} else {
alert('User Canceled!');
}
function main(fileObjs) {
for (var i = 0; i < fileObjs.length; i++) {
var fileName = fileObjs[i].name;
var colorList = customColors(fileObjs[i]);
var thisInfo = fileName + '\t' + colorList;
writeLog(thisInfo);
}
alert('Finished…');
}
function customColors(filePath) {
var colorList = '';
filePath.open('r');
while (filePath.tell() < filePath.length) {
var line = filePath.readln();
if (line.substring(0, 23) == '%%DocumentCustomColors:') {
colorList = line.substring(25, line.length-1) + '\t';
var nextLine ='';
while (nextLine.substring(0, 18) != '%%CMYKCustomColor:') {
var nextLine = filePath.readln();
if (nextLine.substring(0, 18) != '%%CMYKCustomColor:') {
colorList = colorList + nextLine.substring(5, nextLine.length-1) + '\t';
}
}
}
}
filePath.close();
return colorList;
}
function fileFiltering(fileObj) {
if (fileObj.creator == 'ART5' && fileObj.type == 'PDF ') {
return true;
} else {
return false;
}
}
function writeLog(info) {
try {
var log = new File('~/Desktop/Spot_Color_Info.txt');
log.open('e');
log.seek(0, 2);
log.write(info + '\n');
log.close()
}
catch (e) {
alert(e);
}
}
-
5. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 11, 2010 7:36 AM (in response to Muppet Mark-QAl63s)Okay, I'm a total n00b at this. How do I get that to run? I tried pasting it into /Applications/Applescript/Script Editor and hitting the "compile" button, but I get a syntax error "A Identifier cant go after this identifier" and it highlights the first half of the first line "var defaultFolder" before the = sign.
How should I save/execute that script?
-
6. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 11, 2010 7:46 AM (in response to Chris Vreeland)Chris, sorry the above is NOT AppleScript that goes into Apple's Script Editor app. It's ExtendScript, what you need to do to use this is C&P into ExtendScript Toolkit. This should have been installed along with CS and should be situated in you Utilities Folder in 'Adobe Utilities' folder. Open this app make new document paste the above in and save to file with whatever you want to call this with the '.jsx' file suffix/extension. Quit Illustrator pop this file into Illustrators 'Scripts' folder in 'Presets' relaunch Illustrator it should be there. It does NOT actually require Illustrator at all.
Let me know how you get on.
-
7. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 11, 2010 8:12 AM (in response to Muppet Mark-QAl63s)Thanks, I was busy figuring that out just now. :-) It spits out pretty much exactly what I was looking for!
Is there a way to replace the tabs with hard returns (or whatever works) so that the info will paste vertically into cells in the same column instead of horizontally in the same row in Excel?
Edit: what would the changes be to get this to work on individual files instead of a directory? Thanks again!
-
8. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 11, 2010 8:20 AM (in response to Chris Vreeland)Im NOT a big user of Excel at all only have it on my home mac to open the odd file or two. From writing the text file this I think would be much more difficult to do (If you were to do this as batch with multi files for single files NO problem). Is there NO way to flip this data from in Excel?
-
9. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 11, 2010 8:39 AM (in response to Muppet Mark-QAl63s)I'm not a big excel guy, either. The database folks are building me a form into which my data will go -- a column of SKUs, a column for design name, a column for color and a column for mesh count. I'm just looking at ways to reduce text entry. Hitting *return* a few times in the script's resultant text file seems to work for now. :-)
Thanks again!
-
10. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 11, 2010 9:01 AM (in response to Chris Vreeland)If you want this to just output for a single file then it would NOT be a problem to change the script to use returns instead of tabs. I did a quick google and you can switch columns to rows in excel by select all special paste with transpose so that would be the simplest route if you were to batch.
-
11. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 11, 2010 9:26 AM (in response to Muppet Mark-QAl63s)Muppet Mark wrote:
If you want this to just output for a single file then it would NOT be a problem to change the script to use returns instead of tabs.
That is actually what I'd prefer -- I've got to create an entry for each color in the database anyway, so that I can assign mesh counts, so one job at a time would be preferable to doing a whole folder full of files since we've got art files in the archives that are discontinued, and original client files that have not had spot swatches built in them, or are otherwise incorrect/useless.
Are those changes easy enough for you to make? I can pass your script along to one of our IT guys who knows javascript (I try not to bug him too much), if not.
This is really most helpful! Thanks again!
-
12. Re: Script to export swatch names as tab-delimited text?
Muppet Mark-QAl63s Jan 12, 2010 6:12 AM (in response to Chris Vreeland)This may work 4u…
#target illustrator
function main() {
var illFile = new File().openDlg('Please select your Illustrator file…');
if (!illFile instanceof File) {
alert('This is NOT a file?');
return;
} else {
if (illFile.creator == 'ART5' && illFile.type == 'PDF ' || illFile.type == 'EPSF') {
var fileName = decodeURI(illFile.name);
var colorList = customColors(illFile);
var thisInfo = fileName + '\n' + colorList;
writeLog(thisInfo);
alert('Finished…');
return;
} else {
alert('This is NOT an Illustrator file?');
return;
}
}
}
main();
function customColors(filePath) {
var colorList = '';
filePath.open('r');
while (filePath.tell() < filePath.length) {
var line = filePath.readln();
if (line.substring(0, 23) == '%%DocumentCustomColors:') {
colorList = line.substring(25, line.length-1) + '\n';
var nextLine ='';
while (nextLine.substring(0, 18) != '%%CMYKCustomColor:') {
var nextLine = filePath.readln();
if (nextLine.substring(0, 18) != '%%CMYKCustomColor:') {
colorList = colorList + nextLine.substring(5, nextLine.length-1) + '\n';
}
}
}
}
filePath.close();
return colorList;
}
function writeLog(info) {
try {
var log = new File('~/Desktop/Spot_Color_Info.txt');
log.open('e');
log.seek(0, 2);
log.write(info);
log.close()
}
catch (e) {
alert(e);
}
}
-
13. Re: Script to export swatch names as tab-delimited text?
Chris Vreeland Jan 12, 2010 6:30 AM (in response to Muppet Mark-QAl63s)That totally works. Amazing. Wish I could give you two best answers!


