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

Similar Messages

  • 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();

  • 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?

  • [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

  • When I choose a song on my iPhone 5c, it deletes them all except for the ones I have purchased off of iTunes. How do I fix this and why is it happening?

    Ok. So if you didn't know, there are some sites that allow you to download music for free legally. For example many industry artists release "free albums" or "mixtapes" just for their fan base. They are uploaded by the actual artists themselves and downloaded by millions of fans. However when I choose to play one on my iPhone 5c, all of them get deleted except for the iTunes purchased songs. This has never happened before and I would like to know why it is happening now, and how to fix it.
    Thanks.

    Hello yung ron,
    It may be that your iPhone's set to sync automatically, which can potentially remove any music that's been added to the device. It may help to set the device to 'manual mode,' so that you have complete and total control over what content is on the device.
    Managing content manually on iPhone, iPad, and iPod
    http://support.apple.com/kb/HT1535
    Cheers,
    Allen

  • 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

  • I can delete all photos except for one album where no trash can appears. How can I get rid of the album?

    I have an album of photos on my IPAD that I can not delete. It was imported from a camera card. I have managed to delete all other photos taken the same way but these appear to be stuck on the IPAD as no trash can icon appears. Also, my other photos appear in the imported folder and also albums. The photos in the album that won't delete only appear in that album?

    You would get more responses from iMovie users by posting in the iMovie community >  iMovie for Mac: iLife: Apple Support Communities

  • IPhoto deleted whole album except for one photo I had done on the previous day

    I had just completed an album in iPhoto when it suddenly said something like "iPhoto had to unexpectedly shut down". When I went back in, everything I had done that day was gone. There was still one pic left in the album from the day before. How can I retrieve those edited pictures? Help :(

    akbums in iPhoto are not places but views of the photos in your library - look at some of the photos in events or Photos view - do they have the edits?
    You can try Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library database and see if it finds your albums and displayes it
    LN

  • Recently, U2 music appeared on my ipod without my requesting it or wanting it. I was able to delete all of the songs except for one. How do I delete the last one from my ipod? The song does not show up in iTunes when I plug my ipod into the computer.

    Recently, U2 music appeared on my ipod without my requesting it or wanting it. I was able to delete all of the songs except for one. How do I delete the last one from my ipod? The song does not show up in iTunes when I plug my ipod into the computer. The version installed on my ipod is 7.1.2(11D257).

    Hi donfrommars,
    Welcome to the Apple Support Communities!
    Please use the following article for information and instruction on deleting the U2 album from your devices and account.
    Remove iTunes gift album "Songs of Innocence" from your iTunes music library and purchases
    Have a great day,
    Joe

  • Is there a way to delete ALL of my music off of my iTunes/computer EXCEPT for the music that's on my iPod touch?

    I have old music that I have deleted from my iPod that I no longer wish to have on there, but it reappeared in my iTunes.
    All of the music on my iPod I want to keep, and one other CD I've gotten since then. Is there any way to delete everything (for good, this time) except for what's already on my iPod (and another CD, too, if possible?)

    I sounds like you restored the iPod to factory defaults/new iPod.  In iTunes on yur computer go to iTunes Preferences. click on he Ddvices tab.  If the date of the backup file indicate that it it has the history you can restore from that backup.

  • ITunes has deleted all my music except for the genre I was listening to yesterday.  It has also deleted my purchased movies and all my podcasts and playlists.  Grrr

    iTunes has deleted all my music except for the genre I was listening to yesterday.  It has also deleted my purchased movies and all my podcasts and playlists.  Grrr.  Is there a way to find it all again???

    Hey there MotherMarthaMayhem,
    Welcome to Apple Support Communities.
    This article provides information and troubleshooting tips that may help you find the media that recently went missing from iTunes on your MacBook Pro.
    iTunes: Finding lost media and downloads - Apple Support
    Cheers,
    -Jason

  • How to diable delete button in PO for all users excepting one

    Dear All
    Please guide how to disable delete button in PO for all users excepting only one.
    Thanks

    Hi,
    check following link
    [Disable fields at item level in ME22N;
    [Disable Delete Button;
    Regards
    Kailas Ugale

  • Uninstalled Roboform and everything has been deleted except for the icon in my launchpad.

    I just uninstalled Roboform from my mac and all has been deleted except for the roboform icon in Launchpad, drag & drop does not work so am at a loss as to how to get rid of it. All icons in the Applications folder along with all files have gone but this one persists.
    Anyone out there any ideas. The Robofrom site and faq's have nothing on it and contacting them is fraught with setting up user & password so not going there.
    Thanks to all who may respond.

    Simply drag the icon to the trash and empty the trash.
    Cheers
    Don

  • I want to delete all cookies when I close Firefox except for one website. Is this possible?

    I have a website bookmarked that I use frequently and I have set my preferences on the site. I have Firefox set to allow cookies from this site. Is there any provision to delete all cookies except this site when i close Firefox?

    There is a plugin for that, search "cookie" on the plugins site and you'll find it.

Maybe you are looking for