Deleting unused swatches change the gradient

Hi All,
I have tried this Javascript to remove unused swatches in a document (Indesign CS4). It did remove all the unused swatches but it changed the used gradient color into black color and still has the gradient property but couldn't change any color values for that particular gradient after running the script.
#target indesign
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var j=myIndesignDoc.unusedSwatches.length; j > 0; j--)
  myIndesignDoc.unusedSwatches[j-1].remove();
Please advise me where I did wrong and also please suggest the right solution for this.

Hi Friends
Use this script it will help ful.
# target "Deleting unused swatches change the gradient"
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
     var mySwatch = myIndesignDoc.unusedSwatches[s];
     var name = mySwatch.name;
// alert (name);
  if (name != ""){
mySwatch.remove();

Similar Messages

  • [CS3][VBS] Delete Unused Swatches ALSO clears Gradient Swatches!

    Hi Folks!
    Heres another weird one. This code deletes unused CMYK swatches properly but also sets the background of some gradient swatches to black.
    myUnusedSwatches = currentdoc.UnusedSwatches.Count
    For myLoop = 1 To myUnusedSwatches
    On Error Resume Next
    Set myUnusedSwatches = currentdoc.UnusedSwatches.Item(1)
    *** I even through this in as a last ditch solution, but it only works sometimes***
    if instr(lcase(currentdoc.unusedswatches.item(1).name), "gradient") = 0 then
    myUnusedSwatches.Delete
    else myUnusedSwatches.Save
    end if
    Next
    Any ideas?

    I think i've gotten to the bottom of this - the designers have been using 'Paper' as a white background for gradients. When a colour swatch with CMYK 0 is used, the script works.
    If TypeName(currentdoc.UnusedSwatches.Item(1)) = "Gradient" Then
    Doesn't work, unfortunately, because its not actually deleting the gradient, its setting its background colour to black; the unused swatch its deleting is actually a color swatch.
    Since there will be a lot of files here set up this way, can you think of any way to work around this? Why does this not happen when you do the same action in the UI ('select all unsused'> 'Delete')?
    Thanks again Ole!
    Adam

  • Delete unused swatches in InDesign CS5, js

    Hi,
    I need to select and delete unused swatches in InDesign CS5. I looked through OMV in "Swatches" and "Swatch", but I could not find any function to select unused swatch and delete it.
    Am I looking for it in the wrong place?
    And I also need to read color values for used swatches. I got this in OMV and was hoping it would give me an array of the color values for all existing swatches, but I am only getting "Object color":
    mySwatches = myDoc.swatches[1].getElements();
    alert (mySwatches)
    Thank you for your help.
    Yulia

    Hi Yuliaart,
    Try this script it will help ful.
    # target "Deleting unused swatches change the gradient"
    var myIndesignDoc = app.activeDocument;
    var myUnusedSwatches = myIndesignDoc.unusedSwatches;
    for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
         var mySwatch = myIndesignDoc.unusedSwatches[s];
         var name = mySwatch.name;
    // alert (name);
      if (name != ""){
    mySwatch.remove();

  • Need help deleting unused swatches in CS4

    I upgraded from CS3 to CS4, and simultaneously switched platforms from windows to mac osx. Now I can't find the option for deleting all unused swatches in the swatch palette menu and I'm starting to feel insane because I've run several searches and no information about this is popping up anywhere. Can anyone help?

    That's one way, I guess. But in CS3 I was able to select all unused swatches and then drag them to the trash. That way I could still have my default swatches for new projects. But I guess this feature was removed for CS4?

  • Deleting unused swatches except for...

    I have a script that cleans up my document... one of the functions is that it deletes unapplied swatches. This works well for me most of the time but in instances where I'm using a color whose name begins with a "D", I want the script to ignore it.
    In my workflow, "D" represents a digital process and we don't apply a color swatch to digitally printed artwork but a "D" swatch is necessary for our output program to sort the job to the correct printer. The swatch names vary but always begin with a "D" (DBLK, DGLD, DGRN....).
    Thoughts, suggestions?
    Thank you very much for your help.
    //delete unused swatches
    var myIndesignDoc = app.activeDocument;
    var myUnusedSwatches = myIndesignDoc.unusedSwatches;
    for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
         var mySwatch = myIndesignDoc.unusedSwatches[s];
         var name = mySwatch.name;
    // alert (name);
      if (name != ""){
    mySwatch.remove();
    (I found this little script somewhere in these forums - I apologize for not having the credit information available)

    Hi,
    replace the line:
    if (name != ""){
    with:
    if (name != "" && name.search(/^D/) == -1){
    ...(/^D/i) if not case sensitive...
    Jarek

  • Deleting Unused Swatches

    Because I'm unable to invoke the "Select All Unused" menu item of the Swatches panel menu I'm trying to attack it programmatically.
    What I'm trying to determine is if it's sufficient to compare the Fill and Stroke Color of each Path Item (every path item of current document) or are there other items that should be examined to achieve the same results as the command in the Swatches panel menu? Page Items doesn't appear to contain a Fill Color property. I've got AppleScript code that appears to do the trick, but I'd like to get input so as to make sure I'm not missing something that my testing might not have uncovered.
    Thanks!
    Stephan

    Another method might be to remove the extra swatches from the startup files (or New Document Profiles as they are now known) So there are fewer unused swatches to deal with. Relatively few people take the time to modify the action sets aside from adding new ones. Here's how the Delete Unused Panel Items looks in the Default _Actions.aia file
    /action-10 {
        /name (Delete Unused Panel Items)
        /keyIndex 0
        /colorIndex 0
        /isOpen 0
        /eventCount 8
        /event-1 {
            /internalName (ai_plugin_symbol_palette)
            /localizedName (Symbols)
            /isOpen 0
            /isOn 1
            /hasDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette -1
                /type (enumerated)
                /name (Select All Unused)
                /value 12
        /event-2 {
            /internalName (ai_plugin_symbol_palette)
            /localizedName (Symbols)
            /isOpen 0
            /isOn 1
            /hasDialog 1
            /showDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette -1
                /type (enumerated)
                /name (Delete Symbol)
                /value 5
        /event-3 {
            /internalName (ai_plugin_styles)
            /localizedName (Graphic Styles)
            /isOpen 0
            /isOn 1
            /hasDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Select All Unused)
                /value 14
        /event-4 {
            /internalName (ai_plugin_styles)
            /localizedName (Graphic Styles)
            /isOpen 0
            /isOn 1
            /hasDialog 1
            /showDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Delete Style)
                /value 3
        /event-5 {
            /internalName (ai_plugin_brush)
            /localizedName (Brush)
            /isOpen 0
            /isOn 1
            /hasDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Select All Unused)
                /value 8
        /event-6 {
            /internalName (ai_plugin_brush)
            /localizedName (Brush)
            /isOpen 0
            /isOn 1
            /hasDialog 1
            /showDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Delete Brush)
                /value 3
        /event-7 {
            /internalName (ai_plugin_swatches)
            /localizedName (Swatches)
            /isOpen 0
            /isOn 1
            /hasDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Select All Unused)
                /value 11
        /event-8 {
            /internalName (ai_plugin_swatches)
            /localizedName (Swatches)
            /isOpen 0
            /isOn 1
            /hasDialog 1
            /showDialog 0
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette 1
                /type (enumerated)
                /name (Delete Swatch)
                /value 3

  • Deleting unused footage in the Event library?

    I always make an edit of my videos and therefore end up with a fair amount of footage in each event which is not needed any more.
    Is there a way of deleting unused footage from a specific project from it's event?

    Use the Reject Tool to drag with your mouse over the frames you don't need. They will be marked with a red bar underneath. If you want to reject a whole clip, you can right-click and reject the clip that way too.
    Then, select "Rejected Clips Only" in the selection box at the bottom.
    Finally, click "move rejected clips to trash".

  • I need help with changing my e-mail. I just made this account today and I want to delete it or change the e-mail. Help would be very nice!

    Hello can you tell me how to terminate my account(DELETE IT!) or change the e-mail. I went to privacy setting and my e-mail was shown, but nothing about changing it. I went to profile settings and there was nothing about deleting it so any help would be highly appreciated!

    Deleting the iTunes account is not the solution as you will very likely lose any and all purchases ever made with the account.
    If you cannot find the option on the site, contact iTunes support.

  • How do I change the Gradient in the Artwork and Effect Text tool

    How do I change the colors used in the gradient under the Artwork and Effects Text Tool? It always comes green and blue and I dont know how to change it.

    Gradient usually picks up the foreground & background colors from the chips in the tool bar, but that is for the default gradients. Sounds like you have one of the pre-set gradients selected in the drop down list in the gradient options bar. Select the gradient tool, then look in the options bar at the top of the screen. The second item from the left, if I remember correctly, is a drop down list of various gradient possibilities. Select the top left gradient sample for the foreground to background gradient.
    Bob Warren

  • Why can't I find the gradient editor in CS6 to change the gradient overlay color of my text?

    Its here in CS4

    Thanks, but I downloaded it today, I bought it this morning to design a logo... I've been searching google for the past 4 hours and I'm about ready to pull my hair out lol
    I keep finding people with the same problem, look
    I am using photoshop cs6 and following a web tutorial on making a business card. One step I can't figure out.
    "Apply a linear gradient layer style to the warped shape. Use #841618 for the darker color in the gradient and #e82d33 for the lighter color. Once that’s done, use the Move Tool (V) to move the shape near the bottom of the canvas."
    I am in the gradient overlay and I can pick what type of gradient and stuff. But I can not figure out how to change the lighter and darker color for the gradient overlay Maybe this tutorial is pre photoshp cs6?

  • Will my photos be deleted if i change the backup from icloud to pc, will my photos be deleted if i change the backup from icloud to pc

    will my photos be deleted from the ipod if i changed the backup from Icloud to my pc

    No. Nothing will change on the iPod

  • How do I change the gradient so my background colour goes from dark to light?

    I am a relative newbie to PSE. If have tried adding a gradient to my background colour but I have noticeable lines. I need it to go from dark to light from left to right.
    Can anyone help me?
    Mike

    Hi Mike
    You use the gradient tool (foreground to background color)
    e.g set colors to black/white at bottom of tool pallet
    Select gradient tool and set mode to lighten
    Click on top of your image and drag down to the bottom (holding the shift key whilst dragging ensures a vertical line)
    Then release the mouse.

  • My partner has been given an iphone 4 from her father, I have manged to delete and move to her email but need to know how to change the phonebook i.e delete it and change the apple i.d...any ideas?

    Hi All
    My Partner has been given an ipone 4 from her father.
    I have managed to delete his email and set hers up, what I need to do is delete his contacts entirley..would this be able to be done if she connected her ipone to the computer and made herself an apple I.D or is it a matter of reset ?
    Also some pictures on the phone she would like to keep..
    Many thanks

    If her contacts are available in an Address Book app on her computer that is supported for syncing with the iPhone, she can select the supported address book app on her computer under the Info tab for her iPhone sync preferences for syncing contacts. She should be provided a merge prompt or replace the contacts on her iPhone with what is available in the address book app on her computer. Select the 2nd option.

  • JButton Color?! why cant i change the gradient?

    hy iam trying tochange the color of a new ocean l&f Jbutton but the cool gradient gets lost on new color also ive noticed that a object of type Color is recognized but an object of type ColorUIResource is not.
    is this going to be fixed?
    (jdk 1.5.0) calling setBackground on a JButton?
    any ideas?
    i dont wanne write a new l&f for each button with a different color?! (primary1 to primary3)?! but perhaps this is the only solution

    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    public class UIManagerTest {
        public static void main(String[] args) {
            Object[] values = {new Float(0.3), new Float(0.1), Color.GREEN, new Color(0,128,0), Color.BLACK};
            UIManager.put("Button.gradient", Arrays.asList(values));
            JPanel p = new JPanel(new GridLayout(3,3,3,3));
            for(int i = 0; i<9; ++i)
                p.add(new JButton("Here is button #"+i));
            final JFrame f = new JFrame("UIManagerTest");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(p);
            f.pack();
            SwingUtilities.invokeLater(new Runnable(){
                public void run() {
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

  • How do i delete unused apps in the cloud that i no longer use or want

    pleae help me with deleteing apps in the cloud i no longer use or want.

    You can't, you can only hide them.  You can't delete them because they aren't stored in your personal iCloud account (and don't use any of your storage).  Those are links to your previously purchased apps in the App store so you can redownload them.  You can, however, hide them so they won't appear on your purchased list by hiding them in iTunes on your computer as explained here: http://support.apple.com/kb/HT4919.

Maybe you are looking for

  • Camera Card slot shows up as network sharepoint

    I work in a mac environment, five computers running osx 10.5 throught 10.8. they all show one camera card slot on the HP 6500 as a bloody sharepoint! Is there any way to make this card plug stop broadcasting on the network short of ripping out the et

  • Changeip question...

    hi... i need to change the subnet of my xserve... i presume i need to do so using the changeip command but i found this post http://www.afp548.com/forum/viewtopic.php?forum=18&showtopic=12944&highlight=cha ngeip... is that still accurate? if so, how

  • Date in the billing document

    Hi, expert, I have a question about the date of billing doc., If we set up invoicing date for customer-A is at the last day of every month, and SAP billing job only run every workday. Apr.30 is Sunday, so SAP billing job will run on May 1st instead o

  • Cancel line item in crm order

    Hi All, How can I cancel an item of a CRM order? Is this possible through BAPI ? If yes , please mention how. Thanks a lot Ajith

  • Hibernate button greyed out after Windows XP reinstallation

    I recently reinstalled Windows XP in my M35X, one thing Ive noticed is that the hibernate button (which was perfectly functional before) has greyed out and I dont have that option anymore. Any help? Thanx