Remove unused shades except for...

I have a script that cleans my document... one of the features is that it removes the unused nuances. This works well for me most of the time, but in case 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 do not apply a color swatch to the digitally printed illustrations, but a "D" grade is required for our program output to sort the job to the correct printer. Swatch names vary but always begin with a "D" (USB, DGLD, NOTARY...).

Thoughts, suggestions?

Thank you very much for your help.

remove unused shades

var myIndesignDoc = app.activeDocument;

var myUnusedSwatches = myIndesignDoc.unusedSwatches;

for (var s = myUnusedSwatches.length - 1; s > = 0; a--) {}

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 available credit information)

Hello

Replace the line:

if (name != ""){

with:

if (name != "" && name.search(/^D/) == -1){

... (/ ^ D / i) if not broken...

Jarek

Tags: InDesign

Similar Questions

  • Update problem can remove them except for the most recent? Thank you!

    Hello!  In Control Panel, there are about 20 programs that all say the same thing.  They are updated for Windows and IE 8 security.  The only difference is the date, which date as far back as 2010.  Can I remove them except for the most recent?  Thank you!

    # They are all necessary.

  • When I use the truncation tool, select a zone and press return it removes everything except for a single pixel. This just started today. CS5, Windows 7.

    When I use the truncation tool, select a zone and press return it removes everything except for a single pixel. This just started today. CS5, Windows 7. I tried to reinstall CS5 and who did not help. I am trying to set up a new computer and installed Photo Shop CS5 on it earlier in the day. Maybe it has something to do with it. But until I get the new fully configured machine I still want to continue to work on my current machine, which is where the problem is happening.

    Hi haroldschlegel,

    Please try resetting the cropping tool

    Restart Photoshop once done and see if that helps.

    Kind regards

    Assani

  • Remove unused master spreads

    Hello

    I need to remove some unused document masters spreads. If there is any unused master then propagates its removal.  But when there is no unused master spreads, its pop-up below alert. Its deletion pages. I use the code below.

    What is my in the code below.

    Screen shot 2015-08-22 at 8.03.59 AM.png

    function removeUnusedMaster()

    {

    App.Selection = 1851876449;

    If (app.menuActions.itemByID checked (6145) == true)

    {

    try {}

    app.menuActions.itemByID (6151) .invoke ();

    app.menuActions.itemByID (6150) .invoke ();

    } catch (e) {/ / remove spread all except 1st, when all differences are not used except no.}

    app.activeDocument.masterSpreads [1] .select)

    app.activeDocument.masterSpreads [app.activeDocument.masterSpreads.length - 1]. Select (Select ionOptions.addTo);

    app.menuActions.itemByID (6176) .invoke ();

    }

    } else

    {

    try {}

    app.menuActions.itemByID (6145) .invoke ();

    app.menuActions.itemByID (6151) .invoke ();

    app.menuActions.itemByID (6150) .invoke ();

    } catch (e) {}

    }

    }

    Thanks in advance,

    Sudha K

    The alert you see pop up when there is no unused masters gaps, but when you try to delete a master that applies to one or another master page/double. You cannot use menuActions for that I don't think that because you have to be able to tell if a master is applied. With menuActions test is to check if this alert appears, but you cannot script that.

    But it is not too difficult to check if the masters are used: create a list of masters applied to the pages of the document, another list of teachers applied to the masters of the document (i.i. a list of masters end of other masters), then delete the masters that do not occur in any of the lists.

    (function(){
    
      var pages;
      var masters;
      var i;
      var appliedToPages = {};
      var appliedToMasters = {};
    
      // Get the names of the masters applied to document pages
      pages = app.documents[0].pages.everyItem().getElements();
      for (i = pages.length-1; i >= 0; i--) {
        if (pages[i].appliedMaster !== null) {
          appliedToPages[pages[i].appliedMaster.name] = true;
        }
      }
    
      // Get the names of masters applied to masters (i.e. masters based on other masters)
      masters = app.documents[0].masterSpreads.everyItem().getElements();
      for (i = masters.length-1; i > 0; i--) {
        if (masters[i].appliedMaster !== null) {
          appliedToMasters[masters[i].appliedMaster.name] = true;
        }
      }
    
      // Delete masters that are not applied to any document pages or other masters
      for (i = masters.length-1; i > 0; i--) {
        if (!appliedToPages[masters[i].name] && !appliedToMasters[masters[i].name]) {
         // $.writeln (masters[i].name);
          masters[i].remove();
        }
      }
    }());
    

    Peter

  • Cannot upload anything get message that the disc is full... Remove unused files and try again

    I can't download anything. I get a message that the disc is full... Remove unused files and try again... I have deleted many, cleaned the register w/Ccleaner, but doesn't seem to be enough... I don't have the original Windows XP CD... Was already installed. I don't have a recovery CD. Can I use this and start all over again to start on a clean slate? Is there something I can do? I can't yet to update anything.

    I have w/Service pack 3 Windows XP. PC is Dell pentium 4.

    I can't download anything. I get a message that the disc is full... Remove unused files and try again... I have deleted many, cleaned the register w/Ccleaner, but doesn't seem to be enough... I don't have the original Windows XP CD... Was already installed. I don't have a recovery CD. Can I use this and start all over again to start on a clean slate? Is there something I can do? I can't yet to update anything.

    I have w/Service pack 3 Windows XP. PC is Dell pentium 4.

    Please do these two simple things and the report on the results.

    A. report of the disc

    1 double click (or click, if it's in the start menu) Workstation

    2. for each drive (you must be at least 'disc' Local (c), right click and select Properties.  Report of the 'space used', 'Free space' and 'capacities '.

    B. know what is using the space

    1. get a USB that has at least 4 MB of space.  You can buy a 4 GB (this is 1,000 times more that you) thumb drive from Staples for $7.99 and connect it to your computer.

    2. download JDiskReport.  Go to http://www.jgoodies.com/downloads/index.html, make a right click on the link 'Win', choose ' save link under ', navigate to your USB key and save the file.

    3. in the installation: uncheck the 3 boxes on the screen "select components"; on the "Choose installation location" screen, click the Browse button and navigate to your USB key so that all the files will be installed on the USB.

    4. when the installation is complete, click on my computer, open the USB key, open the folder named JDiskReport and double-click on the file named jdiskreport - 1.3.2.jar (you don't see the .jar extension).

    5 scan C: and see what is taking place.

  • Since the update to IE9 uninstall my windows mail is returned to its original settings except for 1 of my email addresses

    Since the update to IE9 uninstall my windows mail is returned to its original settings except for 1 of my email addresses ask again me my user name and password. I type what I think they are but to no avail. I go to tools/accounts/properties and look at my server settings that gives me my username, but I have to use the wrong password. I tried a restore but without success. Help please.

    Hi Steve,.

    I suggest delete the account of the problem and recreate. To do this, follow the steps mentioned in the links below

    Windows Mail: Setting up an account of end-to-end

    http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-mail-setting-up-an-account-from-start-to-finish

    Add-or-remove-a-Windows-Mail-account
    http://Windows.Microsoft.com/en-us/Windows-Vista/add-or-remove-a-Windows-mail-account

  • remove unused pages after copyng to previous pages

    original title: remove unused pages after coptyng to previous pages

    Hi, I have vopy oand CPAST info frompages to prreevios of pages but can not remove unused pages. Can you help me?

    Thank you

    Vicki

    Hello

    A few questions will help us better to solve your problem. Please answer these questions for us:

    1. what operating system do you use?

    2. what programs you have problems with?

    3. is there an error message generated?

    4. what type of file you go when this happens?

    5 How long this issue is past?

    6. is there anything changed/added/deleted before this issue popped up?

    It's basically the who, what, when, where and why of troubleshooting.
    b Eddie

  • Monitor devices blackBerry Z10 - black except for the storage tab

    Hello

    My monitor of the device (from quick settings) is completely empty except for the storage tab. This means that battery, processor, and memory are all does not properly.

    Any suggestions?

    Thank you!

    Hello and welcome to the community!

    Each time a random strange behavior or slowness comes, the first thing to try is a proper reboot:

    • Pre-BB10 ONLY devices. With power ON, remove the hood back and remove the battery. Wait a minute, then replace the battery and cover. Power on and wait patiently through the long reboot - about 5 minutes.
    • Peripheral BB10. Hold the top button until the counter reaches zero. Wait for the unit to be completely stopped (for example, nothing appears on the screen, no lights, etc.). Hold the top button until the red light. Wait through the entire boot process. If this fails, you can try the method of battery-pull above, but it is normally NOT recommended unless nothing else works.

    See if things return to functioning. Like all computing devices, BB suffers from memory leaks and others... with a hard reboot is the best remedy.

    Good luck!

  • Removes all characters except numbers

    Hi all

    I want to reformat to following phone numbers. As you can see it in what follows, I want to delete all characters except numbers and it does not start wirh 0 0 at the beginning of the f-number. And the length is 11. What do you recommend?

    (543) 456-35-50 = > 05434563550

    (555) 555-55-55 = > 05555555555

    (210) 111-11 / 11 = > 02101111111

    Thank you

    Hello

    3018678 wrote:

    Hi all

    I want to reformat to following phone numbers. As you can see it in what follows, I want to delete all characters except numbers and it does not start wirh 0 0 at the beginning of the f-number. And the length is 11. What do you recommend?

    (543) 456-35-50-online 05434563550

    (555) 555-55-55-online 05555555555

    111-11 / 11 (210)-online 02101111111

    Thank you

    To remove all characters except the 10 digits, you can use REGEXP_REPLACE

    REGEXP_REPLACE (str, '\D')

    To put a "0" at the beginning of the string (if it isn't already begin with a '0'), you can use REGEXP_REPLACE even once:

    REGEXP_REPLACE (REGEXP_REPLACE (str, '\D')

    , '^([^0])'

    , "0\1".

    )

    I don't think that there is a way to do both things wih a single integrated function call.

    There is a requirement on the length being 11?  What happens if that comes into conflict with one of the other requirements?  For example, if the string is already long of 11 characters, but does not begin with a '0', do you want to add a "0", which makes 12 characters?  What happens if the length, after removing the numbers no, is very small, say 1?  (You can use LPAD adds however many ' 0 s you need.)  If the length (after removing the numbers) is 12 or more?  What happens if the string does not contain any what numbers at all?

    If these things are questions, then post CREATE TABLE and INSERT statements for some examples of data, accurate results, you want that data, and explanations.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

  • How to remove each layer except the selected layer?

    Hello

    I would like to delete all layers including the background sets and layer except for the selected layer.

    It seems easy to first, but it stops... I tried in several ways; What I am doing wrong?

    #target photoshop
    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };
    
    app.bringToFront();
    var doc = app.activeDocument;
    var currentLayer = doc.activeLayer; // remember the selected layer
    var selectedlayername = currentLayer.name;
    currentLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING );  
    
      function DeleteLayer(layername) {  var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();   ref1.putName(cTID('Lyr '), layername);
        desc1.putReference(cTID('null'), ref1);     var list1 = new ActionList();
        list1.putInteger(17);  desc1.putList(cTID('LyrI'), list1);  executeAction(cTID('Dlt '), desc1, DialogModes.NO);
      };
    
    function DeleteBackground() { var desc1 = new ActionDescriptor();  var ref1 = new ActionReference();   ref1.putProperty(cTID('Lyr '), cTID('Bckg')); desc1.putReference(cTID('null'), ref1);     var list1 = new ActionList();     list1.putInteger(1);   desc1.putList(cTID('LyrI'), list1);    executeAction(cTID('Dlt '), desc1, DialogModes.NO); };
    
    function initial () {
    for(var i = 0 ; i < doc.layers.length;i++){    if (doc.layers[i].isBackgroundLayer == true ) {  DeleteBackground();} }
    var layerNum = doc.layers.length;
    for(var  s = 1 ; s <= layerNum;s++){
       if ( doc.layers[s].name != selectedlayername ) {   
           DeleteLayer (doc.layers[s].name);
           }
       else if ( doc.layers[s].name == selectedlayername ) {
           }
       }
    }
    
    initial();
    

    Thank you

    Best regards.

    Hi arteangelus,

    Try this Code...

    #target photoshop
    var docRef = app.activeDocument;
    var layName = docRef.activeLayer.name
    var l = Number(docRef.layers.length)+1;
    while(--l){
        if(docRef.layers[l-1].name!=layName && docRef.layers[l-1].name!="Background"){
            docRef.layers[l-1].remove();
        }
    else{continue;}
    }
    

    -yajiv

  • Removing unused columns - pre and post checks

    Friends...

    DB: 11.2.0.3

    OS: Linux

    I have a few quick questions in relation to removing unused columns which I intend to do on the production database (5 tables 20 GB each)

    The columns are already defined as unused tables, but I'm trying to get a backup plan for this tables if something goes wrong, while editing the table.

    Could some experts share their experience with me?

    1. What backup plan, I can have 5 tables to retrieve them in case something goes wrong?

    (I thought about import export, but I think import will fail if I try to import after that "alter table drop unused column" did not order)

    Also some tables have 500 lines and taking the export compliance will be problematic.

    2. any request to know in advance which package could be invalid after the fall of the column?

    3. statistical does is invalid?

    (According to my knowledge, I think that it won't affect his stats and also tested this and stale_stats column was not after a column.)

    4. do I need to scan the table or rebuild indexes to ensure that this drop column does not affect the performance of the application?

    5. any other minor/major that keep them in check after a fall unused column?

    Thank you

    Mike

    @rp0428... I understand your doubts and yes it's true, there were 5 tables of 20 GB each and additionally 5 tables, there are a few smaller tables I thought won't create a problem. For large tables, I did used control point.

    As always, I have tested plan in dev environment with the same size/data lines but a unused fall was quick and no problem with cancellations is why during production, it took me surprise.

    I had cancellation of 32 GB, so obviously, I was confident of small tables)<5 gb)="" should="" definitely="" fit="" in="" 32gb="" (but="" it="" wasn't="" the="">

    OK - but we can only go through the information you post and you don't post anything of this.

    If you had my question would be why you do not use "checkpoint" when you tested and why you didn't used it for this 5 GB table in production that generated 100 GB of REMAKING?

    My next question would be: what PROBLEM have you tried to solve by dropping the unused columns? Your application was working fine so why was the decision taken?

    And the reason for this question is that ANY significant changes to a table (standard partitions, add virtual columns, split partition, etc.) is ONLY suitable for technical purposes.

    There are almost always other changes that could / should be made and it is usually beneficial to make all these changes as a whole. Common examples include 1) get rid of the old data (dilation), 2) addition of such constraints as NOT NULL, 3) a table partitioning, 4) adding new columns - perhaps with NOT NULL value and/or default values constraints.

    Since 'other' someof these changes can be problematic if done online, it is generally advised to do a thorough analysis to make sure that you have identified ALL the changes you want, you can then do all at once. Often the best solution is to re-create the table and data using the DEC.

    1. a normal 'drop unused' rewrites all the blocks. It's not moving lines to other blocks - it essentially tightens just online content in order to remove all the content of the unused column.

    2. a normal 'drop unused', even if you use control points, leaving the "unusable" table until the WHOLE picture was treated. This means you NEED to perform the operation before normal re-use of this table, you can resume

    3. a normal life 'unused drop' will NOT free space which can be used by other objects - the same lines occupy the same blocks - the lines are just "small". Therefore, there is NO space to release.

    Creating a table (e.g. DEC) you can use a bulk loading and parallel operations and move lines of new blocks. It can also if take care of these 'other' I mentioned with little or no extra charge of the changes.

  • Remove unused paragraph Styles - without basedOn styles

    Hi all

    I have remove the unused paragraph style, re-flow the pattern content also deleted "basedOn" style.

    How to avoid remove basedOn styles.

    Example here:

    1. I have not used the '06 extract"style of paragraph directly in paragraphs (texts), so it's the unused paragraph style.

    2. I applied "06 extract 1 P" style of paragraph directly in paragraphs (texts), but connected the pstyle "06 extract" to indirectly ' 06 1 P "(avec l'option basedOn) see below excerpt.". "

    Removing unused styles, the "06" excerpt has also removed and affects '06 extract 1 P. So, re-flow occurring in this document, how to avoid this? No need to remove by using the 'basedOn' styles (example: "06 extract").

    Screen shot 2015-10-12 at 3.27.12 PM.png

    myDoc var = app.activeDocument;

    var myParStyles = myDoc.paragraphStyles;

    var myCharStyles = myDoc.characterStyles;

    for (I = myParStyles.length - 1; i > = 2; i--) {}

    removeUnusedParaStyle (myParStyles [i])

    }

    for (I = myCharStyles.length - 1; i > = 2; i--) {}

    removeUnusedCharStyle (myCharStyles [i])

    }

    function removeUnusedParaStyle (myPaStyle) {}

    app.findTextPreferences = NothingEnum.nothing;

    app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.appliedParagraphStyle = myPaStyle;

    var myFoundStyles = myDoc.findText ();

    If (myFoundStyles == 0) {}

    myPaStyle.remove ();

    }

    app.findTextPreferences = NothingEnum.nothing;

    app.changeTextPreferences = NothingEnum.nothing;

    }

    function removeUnusedCharStyle (myChStyle) {}

    app.findTextPreferences = NothingEnum.nothing;

    app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences.appliedCharacterStyle = myChStyle;

    var myFoundStyles = myDoc.findText ();

    If (myFoundStyles == 0) {}

    myChStyle.remove ();

    }

    app.findTextPreferences = NothingEnum.nothing;

    app.changeTextPreferences = NothingEnum.nothing;

    }

    Thank you in advance,

    Dev

    before checking if the paragraph style is in use, check if all other models are based on it. something on the lines of (warning code, bad, inefficient to come):

    for (i = myParStyles.length - 1; i >= 2; i--) {
        for (var z = 0; z < myDoc.allParagraphStyles.length; z++) {
            var goodToRemove = true;
            if (myDoc.allParagraphStyles[z].basedOn == myParaStyles[i]) {
                //mark the parastyle as not to remove
                goodToRemove = false;
                break;
            }
        }
        if (goodToRemove) {
            removeUnusedParaStyle(myParStyles[i]);
        }
    }
    
  • remove unused resources, while being sensitive to the related assets

    How can I remove unused assets from my library?

    Of course, the easy answer is to verify the account of its use and remove anything from scratch.

    But, how can ensure me that I don't remove an asset that has a counter for the use of zero, BUT is loaded by Actionscript?

    Is the library > select unused items sensitive to this?

    Thanks for your comments.

    Hi Greg,.

    In Flash Pro when you right-click in the library and choose "Select unused items" symbols with link names get selected. Thus the cases you mentioned above is supported.

  • Call except for dialog web and devices

    can anyone tell me how please call script except for the devices and web dialog box...

    Hi rajaramasami,

    You can find examples for example in JavaScript for save for Web, here in the forum.

    In one, written by Paul Riggott:

    Paul Riggott wrote:

    Here you are...

    function main(){
    if(!documents.length) return;
    var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    var saveFile = File(Folder.desktop + "/" + Name + ".jpg");
    if(saveFile.exists){
       if(!confirm("Overwrite existing document?")) return;
        saveFile.remove();
        }
    SaveForWeb(saveFile,100); //change to 60 for 60%
    }
    main();
    function SaveForWeb(saveFile,jpegQuality) {
    var sfwOptions = new ExportOptionsSaveForWeb();
       sfwOptions.format = SaveDocumentType.JPEG;
       sfwOptions.includeProfile = false;
       sfwOptions.interlaced = 0;
       sfwOptions.optimized = true;
       sfwOptions.quality = jpegQuality; //0-100
    activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
    }
    

    Have fun

  • IDCS6 MACOSX JS: script of 'remove unused layer' is not from masters of the masters

    Hello everyone.

    I have an old script I've used several times to remove the unused layers. Until today, I thought that worked well:

    var layers = app.documents[0].layers.everyItem().getElements();
    for(var i=layers.length-1;i>=0;i--){
      if(layers[i].pageItems.length==0){
        layers[i].remove();
      }
    }
    

    However, today, I used the script on a document that was a never used layer once on a master page to which other master pages have taken place on the basis. To my surprise, when the script is run, this specific layer has been removed.

    my knowledge of the script is poor, but looking at the script, it seems that the script is looking at all the layers that have something in them and any layer comprising any element should be removed. However, I think that only made pageItems refers to the regular pages or template, not masters BASED ON other masters.

    I think that the problem is similar to another that I had recently where I had a script that has removed the unused masters, but deleted that other masters masters took place on the basis, and I think that the principles are the same. This thread can be found at:

    http://forums.Adobe.com/message/5922004#5922004

    In short, the script that worked there were as follows:

    xUnusedMasters(myDoc);
    
    function xUnusedMasters( docRef ) {
    var mpNames = new Object () ;
    var allPages = docRef.pages ;
    for ( var pIndex = allPages.length - 1 ; pIndex >= 0 ; pIndex-- ) {
    mpNames = addMasterName ( mpNames , allPages[pIndex] ) ;
    }
    
    var allMasterPages = docRef.masterSpreads ;
    for ( var mpIndex = allMasterPages.length - 1 ; mpIndex >= 0 ; mpIndex-- ) {
    if ( ! mpNames[allMasterPages[mpIndex].name] ) {
    allMasterPages[mpIndex].remove() ;
    }
    }
    return ; 
    
    function addMasterName ( MPDB , pageRef ) {
    if ( pageRef == null ) { return MPDB ; }
    if ( pageRef.constructor.name == 'MasterSpread' ) {
    MPDB[pageRef.name] = true ;
    }
    return addMasterName ( MPDB , pageRef.appliedMaster ) ;
    }
    }
    

    is it possible to modify the script above so that instead of remove unused pages of masters, it takes away the layers used in a similar way?

    Thank you very much

    Colly

    Hello

    Maybe a little differently...:

    Array.prototype.filter = function(collection) {
              var k, i, con, ids = collection.everyItem().id;
              con: for (k = ids.length - 1; k >=0; k--)
                        for (i = 0; i < this.length; i++)
                        if (this[i].id == ids[k]) {
                             ids.splice(k, 1);
                             continue con;
                             }
              return ids;     // array with unmatched ids from collection
              }
    
    var
              mL = app.activeDocument.pageItems.everyItem().itemLayer,
              mUnusedLayersID = mL.filter(app.activeDocument.layers),
              len = mUnusedLayersID.length;
    
    while (len-->0)
              app.activeDocument.layers.itemByID(mUnusedLayersID[len]).remove();
    

    mL is a table with a layer of each pageItem;

    filter compared to the collections of doc.layers;

    unmatched ways not so used are deleted.

    Jarek

Maybe you are looking for