Batch replace color with another color

Hi,
I would desperately need some assistance in trying to accomplish batch editing of ai-files via JavaScript.
What I would need to do, is go through a number (many!) of files, find items with certain swatch color (referenced by its name), and replace the item-fill with another swatch-color (also referenced by its name). Then save the document with another name.
Other parts I have managed to do, except find/compare/modify the fill color of an item.
I have gone through these forums and tried a number of things to a point where I am currently very confused and frustrated 
Some details (if it helps any), I'm using Illustrator CS3 and JavaScript.
Here's the closest where I got with trying to find a certain color and eventually changing it:
#target illustrator
var sourceFile, findColor, replaceColor;
sourceFile = new File().openDlg('Please select your Illustrator file…');
open(sourceFile);
var docRef = app.activeDocument;
findColor = docRef.swatches.getByName("vih");
// replaceColor not yet used anywhere
replaceColor = docRef.swatches.getByName("sin");
for(var obj = docRef.pageItems.length - 1; obj >= 0; obj--) {
    if(docRef.pageItems[obj].fillColor == findColor) {
        alert("Match found"); //It never seems to get here, so my comparison clearly is not working?
    else {
        alert ("No specified color found!");
docRef.close();
(and yes, I'm completely new with java-scripting, so even this is constructed from bits of sample-scripts and other scripts found from these forums)
Please, I would really appreciate any help, this can't really be such a difficult task to do... can it?
BR,
Johanna

I only tried a very basic test in my case ALL path items were filled with various CMYK swatches and the swap did take place so the comparison did work. I would suspect that you have a path item that contains NO fill so any of its properties would be undefined. You can also include this in your code too. This should work for both filled and stroked path items in CMYK art.
#target illustrator
var docRef = app.activeDocument;
with (docRef) {
var findColor = swatches.getByName('vih').color;
var replaceColor = swatches.getByName('sin').color;
for (var i = 0; i < pathItems.length; i++) {
if (pathItems[i].filled == true) {
with (pathItems[i].fillColor) {
if (cyan == findColor.cyan && magenta == findColor.magenta && yellow == findColor.yellow && black == findColor.black) {
$.writeln('True');
cyan = replaceColor.cyan, magenta = replaceColor.magenta, yellow = replaceColor.yellow, black = replaceColor.black;
} else {
$.writeln('False');
if (pathItems[i].stroked == true) {
with (pathItems[i].strokeColor) {
if (cyan == findColor.cyan && magenta == findColor.magenta && yellow == findColor.yellow && black == findColor.black) {
$.writeln('True');
cyan = replaceColor.cyan, magenta = replaceColor.magenta, yellow = replaceColor.yellow, black = replaceColor.black;
} else {
$.writeln('False');
//saveAs(filePath, saveOptions)

Similar Messages

  • HT204053 If I delete an apple ID from my device (ipad) in order to replace it with another, will I lose all the apps that are already on the device or will they stay there?

    If I delete an Apple ID from my device (ipad) in order to replace it with another Apple ID, will I lose all the apps/itunes/etc. that are already on the device or will they stay there?

    It won't delete anyting, it will only change the ID.

  • My new apps have changed to try within creative cloud; and my installed apps will not authenticate.  I recently canceled one subscription and replaced it with another.

    My new apps have changed to try within creative cloud; and my installed apps will not authenticate.  I recently canceled one subscription and replaced it with another.  Can you please look at it and correct?

    Solution for Windows 8.1: Locate the C:\Users\USER\AppData\Local\Adobe\OOBE folder.  Log out of Creative Cloud and from Task Manager end task for Creative Cloud.  From the OOBE folder delete ALL files.  Do not delete folders (com.adobe.accc.apps & com.adobe.accc.home).  When complete, restart Creative Cloud and log in with ID and Password. 

  • Batch replace color without using swatch as source

    I've searched these forums and the rest of the web trying to find a method to do this... Actions don't cut it (if Actions were able to record the "replace color" dialoge it would be fine) so I've turned to scripts, but I have almost no knowlege on this.
    I checked out this thread:
    http://forums.adobe.com/message/2588737
    and it is very close, except that it assumes that there is a named swatch as the source color - which there isn't.
    The script I tried was .JS
    I'm trying to have the script run on a bunch of .eps files in a folder:
    - Select object which has specified CMYK value (0,7,34,10)
    - Replace fill color of the selected object with another CMYK value (5,19,36,0)
    - Save over the existing .eps
    - Close
    - Make coffee (optional)
    Also, any books you can recommend for learning this stuff? For a noob.

    Muppet Mark wrote:
    How simple are you documents as a piece of illustrator artwork. Having a better idea of their contents lets us know how deep the script would need to dig to find the colors you wish to exchange? Just path items? used in text? used to color up placed artwork?
    Hey Muppet Mark,
    If you have other script for all possible objects with also stroke or not, it should be useless (i beggining this script, your point of view should be interresting , personnaly i'm blocked on GraphItems and other complex Items)
    Regards, art.chrome
    #target Illustrator
    var doc=app.activeDocument;
    var couleur= new Array()
    ///////////////// Function ////////////////////////
    var couleurCMYKColor = function (myColour){
         var Couleurs= new Array();
         Couleurs[0]=myColour.fillColor.cyan;
         Couleurs[1]=myColour.fillColor.magenta;
         Couleurs[2]=myColour.fillColor.yellow;
         Couleurs[3]=myColour.fillColor.black;
         alert("CMYK\n"+Couleurs);
    return Couleurs;     
    var couleurRGBColor = function (myColour){
         var Couleurs= new Array();
         Couleurs[0]=myColour.fillColor.red;
         Couleurs[1]=myColour.fillColor.green;
         Couleurs[2]=myColour.fillColor.blue;
         alert("RGB\n"+Couleurs);
    return Couleurs;     
    var couleurGrayColor = function (myColour){
         var Couleurs= new Array();
         Couleurs[0]=myColour.fillColor.gray;
         alert("Gray\n"+Couleurs);
    return Couleurs;     
    var kindColor = function (mekind){
    var kind=mekind.fillColor.toString();
         switch (kind){
               case "[CMYKColor]":
               var result=couleurCMYKColor (mekind);
               break;
               case "[GrayColor]":
               var result=couleurGrayColor (mekind);
               break;
               case "[RGBColor]":
               var result=couleurGrayColor (mekind);
               break;
               default:
               alert("This type of Color ("+kind+") wasn't implemented...");
               break;
    var type = function (me){
         with (me){
          switch(typename){
               case "CompoundPathItem":
               // do nothing useless
               break;
               case "GraphItem":
               // ARGGG !! blocked
               break;
               case "GroupItem":
               // do nothing useless
               break;
               case "LegacyTextItem":
               break;
               case "MeshItem":
               break;
               case "NonNativeItem":
               break;
               case "PathItem":
               var mekind=me;
                   kindColor(mekind);
               //alert (result);
               break;
               case "PlacedItem":
               // do nothing
               break;
               case "PluginItem":
               // procced as a group ?
               break;
               case "RasterItem":
               // do nothing
               break;
               case "SymbolItem":
               // complex.. i don't know
               break;
               case "TextFrame":
               var mekind=me.textRanges[0];
               kindColor(mekind);// the first characters
               break;
               default:
               alert("not implemented...");
               break;
    //////////////// End Function /////////////////////////
    for (c=doc.pageItems.length-1;c>-1;c--){
           var sel=doc.pageItems[c];
          if (sel.selected){
         alert(c+": "+sel.typename);
          type(sel);
          //alert(doc.selection[c].typename);

  • Backup DC past tombstone and need help replacing it with another DC with the same name and IP

    Hey Everyone
    We have a single domain in a forest with 2 DCs with AD integrated DNS configured. The primary DC with all the FSMO roles is a VM (Server 2008 R2) and the backup DC is a physical server (Server 2008 non-R2).
    The backup DC's hardware is very old and has been giving us a lot of issues where the system would intermittently BSOD, freeze, black screen only etc. and as a result, the server was turned off for a very long time, definitely beyond the default tombstone
    lifetime of either 60 or 180 days.
    We want to replace this bad backup DC with another physical server which became available as a spare and is much newer and in a working condition hardware wise. We also wish to ultimately give it the same name (FQDN) and IP to basically make it an outright
    replacement for the current bad backup DC.
    My questions are:
    1.) If we are in a position where the bad server could possibly physically boot and start the operating system and have network connectivity, will we be able to use DCPROMO as one would normally do to demote this DC, or will it have to be done forcefully,
    while keeping in mind as I said that the DC is way past the tombstone lifetime period?
    2.) If it has to be done forcefully, I am aware that the meta data needs to be cleaned up in AD on the working primary DC, although I have never performed such a process before. If this is done, are there any other things I need to look out for or do
    before I attempt to replace it with the other server which I will set up wit the same name (FQDN) and IP, then add to the domain, and then lastly promote as per normal using DCPROMO?
    I know we will have to upgrade the scema to 2012RM as the replacement backup DC will be running this newer operating system.
    Anything else you wish to add or point out to me would be highly appreciated. Thank you in advance.
    Regards,
    CTV

    Hi,
    I would suggest please do the metadata cleanup using the script and then remove object from below DNS console and then run the repadmin /syncall /Aed
    https://gallery.technet.microsoft.com/scriptcenter/d31f091f-2642-4ede-9f97-0e1cc4d577f3
    Repeat running the vbs script till the wrong/unnecessary dc’s are removed.
             Cross check the removal – dsa.msc [ad users and computers] > Domain Controllers OU
     Adsiedit.msc
     Expand domain partition, select OU=Domain Controllers, make sure only the necessary domain controllers are listed.
     Delete the incorrect domain controllers.
    Dnsmgmt.msc [Dns Management]
          Expand the forward lookup zones\_msdcs folder
    i.      Make sure only the actual domain controllers are listed, delete wrong Alias recordsremove wrong name server records
    ii.      Select the container [forward lookup zones\_msdcs.domain.com\dc\_sites_\sitename\_tcp] > delete incorrect _ldap and _kerberos records are listed.
    iii.      Select the container [forward lookup zones\_msdcs.domain.com\dc\_tcp] and delete incorrect _ldap and _kerberos records
    iv.      Expand the [forward lookup zones\_msdcs.domain.com\domains\guid\_tcp] and delete incorrect _ldap entries
    v.      Select [forward lookup zones\_msdcs.domain.com\gc] – delete incorrect HostA records
    vi.      Expand the [forward lookup zones\_msdcs.domain.com\gc\_sites\sitename\_tcp] – delete incorrect _ldap entries
    vii.      Select the [forward lookup zones\_msdcs.domain.com\gc\_tcp] – delete incorrect _ldap entries
    viii.      Select the [forward lookup zones\_msdcs.domain.com\pdc\_tcp] – delete incorrect _ldap entries
          Expand the forward lookup zones\domain.com folder
    i.           
    Delete Host(A) records of dc’s which are non-existant.
    ii.           
    Correct the NameServer (NS) records
    iii.           
    Follow steps similar to ’ A ii ‘ >> ‘ A viii’
             Dssite.msc [Sites and Services]
          Expand the [Sites\Sitename\Servers] – delete incorrect server’s
    B.      Delete incorrect subnet configurations [Sites\Subnets]
          Delete incorrect site links [Sites\IP]

  • How do I delete my email address that is paired with my Droid and replace it with another email address?   thanks!

    How do I delete the email address that Veriozon Wireless rep paired with my Droid and replace it with a different address?

    The easiest way would be to go to menu>settings>accounts & sync, select the account (I'm assuming you're referring to your gmail account, so select google), then press the remove account button at the bottom.  You may lose all your contacts and other data associated with your google account, possibly even your apps, so be aware of this beforehand.  You can then add the new account from the accounts & sync menu. 
    If you are willing to completely start over with your phone, another alternative would be to factory reset it (menu>settings>privacy>factory data reset).  This will return your phone to an out-of-the-box condition, and you can use a different gmail address if you like.

  • How do you remove a person from a photo and replace her with another person

    How do you remove a person from a photo and repalce her with another person.

    There are many tool and "tricks" to accomplish this manipulation. However, depending on the image one technique might be more appropriate than an other. And then there is the question of how to do it "skillfully". For example, the shadows in the person that is being substituted might be different than in the original image creating the obviously "photoshopped" look.
    Doing an Internet search on your posting title brings up lots of examples.

  • How do I find all of one color in a line drawing and replace it with another color?

    Greetings, I'd like to replace this goat-puke green color with "black."
    I have tried everything, but can't find the right command. I'm sure that nothing could be easier, but I'm stumped and will probably smack myself in the head when I see the answer.  lol  Please help.
    Cheers. - Frank

    Ctrl-shift-u (windows) cmd-shift-u(mac) - desaturates
    ctrl-i(windows) cmd-i(mac) - inverts
    ctrl-l(windows) cmd-l(mac) - levels
    In the levels dialog box there are three triangles in the middle window, drag the far left triangle towards the right until your text is completely black. Oh yeah this also takes your black background and makes it white BTW the effect of the invert command.

  • How do I unregister a serial number for LR and replace it with another one?

    Hello
    I got LR3 with my Leica M9. Now I sold my M9 and I'm waiting for the next Leica M to arrive in the next few months. Since LR is more or less part of the Leica-Software, I sold it with it and for the time, while I waiting for the next M, I bought a new LR-License.
    Now I want to give the buyer of my camera the license number for the LR3, that came with the M9 and the LR4-update to it, so he can use it with the camera.
    My problem is now, that I can not unregister the license-number in my Adobe-account for the old LR. How do I do that? After unregistering I want to install my new LR, that just arrived today and register it, but I'm afraid, that I have two registered LR4 versions then and can't give the solde one to the buyer of the camera.
    Thanks for any help and best regards!

    Excerpt from the Lr EULA:
    4.4 No Transfer. YOU MAY NOT RENT, LEASE, SELL, SUBLICENSE, ASSIGN OR TRANSFER YOUR RIGHTS IN THE SOFTWARE, OR AUTHORIZE ANY PORTION OF THE SOFTWARE TO BE COPIED ONTO ANOTHER INDIVIDUAL OR LEGAL ENTITY'S COMPUTER EXCEPT AS MAY BE PERMITTED HEREIN. You may, however, transfer all your rights to use the Software to another individual or legal entity provided that: (a) you also transfer this agreement, (ii) the serial number(s), the Software and all other software or hardware bundled, packaged or pre-installed with the Software, including all copies, upgrades, updates and prior versions, and (iii) all copies of font software converted into other formats to such individual or entity; (b) you retain no upgrades, updates or copies, including backups and copies stored on a computer; and (c) the receiving party accepts the terms and conditions of this agreement and any other terms and conditions under which you purchased a valid license to the Software. NOTWITHSTANDING THE FOREGOING, YOU MAY NOT TRANSFER EDUCATION, PRE-RELEASE, OR NOT FOR RESALE COPIES OF THE SOFTWARE. Prior to a transfer Adobe may require that you and the receiving party confirm in writing your compliance with this agreement, provide Adobe with information about yourselves, and register as end-users of the Software. Allow 4-6 weeks to transfer. Please visit http://www.adobe.com/supportor contact Adobe's Customer Support Department for more information."
    For full text of EULA see here: http://labs.adobe.com/technologies/eula/lightroom.html

  • Variable replacement path with another variable

    Hi Guru's
    I'd like to use the functionnality of replacement path from a variable.
    Well, i have variable V_1 which is a basic manual entry variable based on a date infoobject. this variable is not mandatory and accessible.
    And i have the variable V_2 which should be based on V_1 so i created V_2 with a process replacement path and in the replacement tab i put V_1 (i try with the list but i didn't find my V_1)
    But the result is that V_2 is always empty but i have no problem when i check the query
    So do you have any idea ?
    Why i can not see the V_1 in the list of variable from the replacement ?
    I don't want to use by exit. i know that it is possible but i want to use the main simple functionnality for flexibility is maintenance by users.
    Thanks for help
    Cyril

    thanks for your answer,
    svu123, my V_1 variable is of course in a correct status to be used. i made test in first without V_2.
    And when i create V_2 in the first tab i activated correctly the replacement in processing type. if not i can not choose
    the query or variable source and i can not see the list of variables.
    Rakesh, i tried what you answered without results. i check different variables that are available in the list and i have
    lots of different variables (all in ready for input) but i have interval, multiple single values, SAP standard variables my own variable on other fields.
    any other ideas ?
    many thanks
    Cyril

  • Does anyone know why my phone deletes my contacts and replaces them with another devices after i restore it to the origninal contacts?

    i recently upgraded iPhones and so did my mum so when i was setting them up i linked the icloud between the two and since then my phone will only keep her contacts even if i restore my phone back to my old phones settings. when i have restored to my old phones settings it will hold the contacts i use to have for about 1-2mins and after that it will delete all of them and then replace with the numbers on my mums phone.. is there any way around this because i am getting frustrated that i cant access my old contacts. i have deleted the previous back ups to my old phone but has made no difference :/

    Your problem is that just after restoring your device, it than syncs with icloud, finds that icloud has you mum's data and so deletes everything on your device and downloads her data.  The issue here is that you and your mum are using the same icloud account - you should each have your own account
    Read this link, it covers how to recover from lost contacts from an icloud backup.  It's not quite what you need, but the discussion about how to stop syncing just after performing a restore is important to you.  Good luck.
    https://discussions.apple.com/docs/DOC-4841

  • Why is my battery life so bad on my iphone 4s. I signed up for a 2 yr contract with a new iphone 4s. The battery life didn't last a day. I went back to Apple and they replaced it with another iphone 4s. This one is just as bad. The iOS 5.0.1 does nothing!

    I have never been so disappointed with an Apple Product such as the Iphone 4s. When I signed up with a new 2 year contract, I received my iphone 4s. I charged it fully the night before, then it didn't even last the day (with minimal usage). I turned off Location Services, Wi Fi, and Bluetooth, this helped a bit. But what is the point of turning these services off, when I NEED THEM!!!  The wonderful new Siri doesn't work properly without Location Services turned on.
    So I upgraded to the iOS 5.0.1. version - that did absolutely nothing to assist the battery life.
    Apple, what are you going to do about it?  My new Apple phone is a LEMON!
    If I had of known how bad the battery life is on the iphone 4s, I would have got a Samsung Galaxy 2!!!!!

    It doesn't really matter whether I am talking to Apple or not (and I'm sure they monitor these comments), I want everyone to know how bad this new iphone 4s is, and all of it's problems.
    Apple have already launched an upgrade to the software - it obviously did not help, as many around the world would concur.
    As far as being patient and waiting for another "update in the works" is concerned, it is just not satisfactory. This is not a cheap phone, and those who are experiencing these problems, should not have to be paying a substantial amount of money, for a very smart phone, that obviously, has some serious problems.

  • Replacing HH2 with another router

    Hi folks,
    I'm going to be replacing the HomeHub v2 with a shiny new Netgear WNR3500L sometime in the next few days.
    A quick question (or two, actually ) - 1. What's the "recommended" procedure for installing a new router? I'm assuming that it's something along the lines of "1. Power down all network equipment; 2. Power down HH2; 3. Power down OR modem" then just doing the reverse of the above to connect the new router.
    Second question - When I initially set the new router up, obviously I will have to configure the web interface to connect via PPPoE and use the HH's login credentials - Will this cause the OR modem to resynch? I obviously don't want too many resynchs, as I have a max profile which I would like to keep tyvm.
    Thanks in advance for any thoughts/suggestions/help.

    loonboy In message 10 of THIS thread has done a similar thing, and appears to be easy....
    "the home hub 3 is jsut rubbish, i tried every setting in there and ended up buying a new router myself
    i got the netgear n750 and i got to say it was just plug in and throw the setup disk in ti and it was away".
    Please Click On any Text in Blue as that automatically links to information.
    PC (NDEGR)

  • W520 Replace DVD with another Hard Drive and IEEE 1394 spec for music recording

    To increase the performance, I am taking the 160 GB SSD instead of the mechanical drive. Obviouslt, I need more space than this. I don't care about the DVD rom. It can't play blu ray anyway. Is it possible to replace the dvd drive with a hard drive? Where can I get a replaceable drive for this? What do I do with the DVD? Can I sell it back?
    I need to do music recording with this. I was wondering about the IEEE 1394 spec; the latency etc. If I remember correctly the W510 IEEE1394 was very good, probably was manufactured by Texas Instruments. I could not find anything about it anywhere. Not even here: http://www.lenovo.com/psref/pdf/tabook.pdf
    Also, a bit worried about the sound card. How good is it? Did anyone use this laptop for music recording?

    hey udvranto,
    with regard to this, i would suggest contacting tech support via the number listed in the link below to check if it is possible to replace the dvd with your harddrive.
    http://www.lenovo.com/contact/us/en/
    on the part of the soundcard, I believe it is good for music recording. Though this really depends on the software that you're going to use to record.
    WW Social Media
    Important Note: If you need help, post your question in the forum, and include your system type, model number and OS. Do not post your serial number.
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"!
    Follow @LenovoForums on Twitter!
    Have you checked out the Community Knowledgebase yet?!
    How to send a private message? --> Check out this article.

  • My-bluetooth-keyboard-with-mac-mini-10.7.5-spacebar-anddelete-keys-do-not-respon d-tried-replacing-keyboard-with-another-and-have-the-same-problem

    my-bluetooth-keyboard-spacebar-and-delete-not-responding-mac-mini-10.7.5-replace dkeyboard-same-issue-with=new-keyboard

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether your problem is caused by third-party system modifications that load automatically at startup or login. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click  Log in.
    *Note: If FileVault is enabled under OS X 10.7 or later, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

Maybe you are looking for

  • Please help: trying to install Oracle 8.1.6.0 on Mandrake 8.1

    Hi, I am trying to install Oracle8i that comes with "Oracle for Linux Starter Kit" on Mandrake 8.1. Could someone please give tips or pointer how i can accomplish this? The Universal Installer starts fine, but then a dialog pops up about compiling sq

  • Displaying MS Word File in browser

    Hello, Can anyone pls tell about the method to display MS word file present in a folder in my site on the browser. I dont want it to give it as download dialog box. Thanks Sharath

  • Vendor Master Changes Tracking

    Dear Friends, I want to find out the chages made in Vendor Master for specific field. Please let me know how to find user details who made changes in Vendor Master. Thannks in advance. Regards, JD

  • G580 processor upgrade

    In my g580 I currently have Intel Celeron b820, but I want to replace it with Intel Core i3-380M Processor (PGA988), as I can see, it would fit in (tdp, socket, etc..). What do you think guys? If not this one, wich one would be a good replace (I am c

  • Garbage found in Index Marker

    Hi Guys, My FM files are Chinese, but in English OS Locale, the Index Marker displayed as garbage (please see below screenshot). Could we resolve this issue by changing the code page for the marker in FrameMaker? If yes, how to do it? Thanks in advan