Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Remove ALL unused colors from ALL open docs

Enthusiast ,
Dec 04, 2019 Dec 04, 2019

Hello,

 

Is there any way to have InDesign Select ALL unused Colors and Delete them automatically from ALL open documents?

Best,

Babs

TOPICS
How to , Scripting
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 04, 2019 Dec 04, 2019

You can use either javascript or AppleScript. If you want to compile with Script Editor this Applescript will work:

 

 

tell application "Adobe InDesign CC 2018"
	repeat with x in every document
		tell x
			delete unused swatches
		end tell
	end repeat
end tell

 

Translate
Contributor ,
Dec 04, 2019 Dec 04, 2019

Hi,

here is a modified script that is based on a script that I found somewhere in the old forum.

var allDocs = app.documents;

for (var i = 0; i < allDocs.length; i++) {
	trashUnusedSwatch (allDocs[i]);
}

function trashUnusedSwatch(myDocument){
	var id, sw;
	
    while (myDocument.unusedSwatches[0].name != "") {

            id = myDocument.unusedSwatches[0].id;

            sw = myDocument.swatches.itemByID(id);

            sw.remove();

        }

    }

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 04, 2019 Dec 04, 2019

Hello and thank you!

However, I was not able to compile the code without an error?

I was able to find this script below and I added it to my scripts in InDesign and it works for the current open document, but, trying to figure out how to write it so it does the action to ALL open docs..

 

tell application "Adobe InDesign CC 2018"

tell active document

delete unused swatches

end tell

end tell

 

I assume changing "active Document" to something else, might work, but everything I try will not compile.

Any thoughts would be greatly appreciated.

 

Thank you ,

Babs 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

Hi Babs,

crazyPanda's code is not AppleScript code.

It's for ExtendScript (JavaScript).

 

How to work with ExtendScript-code:

http://www.indiscripts.com/pages/help#hd0sb2

 

FWIW: It will remove all unused swatches that are named.

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 04, 2019 Dec 04, 2019

Hi Ewe,

Thank you..I have actually been looking at this page, not sure how I found it, but slowly reading through it, as this is very different than anything I have seen, but it looks like the latest stuff for InDesign... 

Have not found anything yet, on any site that helps with this issue, as I cannot move the items from their initial folder, so I can't do a bactch to a folder. Has to be for ALL the open documents... Was hoping that one line could have a simple syntax change to address all the docs? So, I will keep digging for that,

But going to look more at this ExtendScript page... so thank you!
babs 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2020 Mar 04, 2020

Thank you for this script. It worked well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2025 Apr 24, 2025

How can i change this script to only work for the active document im currently in and not for all open documents?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2025 Apr 24, 2025
LATEST

Hi Enrico,

I changed the ExtendScript code that was posted by @crazyPanda  so that the script will run only at the active document. Warning: had no time for testing!

 

var doc = app.documents[0];

trashUnusedSwatch( doc );

function trashUnusedSwatch(myDocument){
	var id, sw;
	
    while (myDocument.unusedSwatches[0].name != "") {

            id = myDocument.unusedSwatches[0].id;

            sw = myDocument.swatches.itemByID(id);

            sw.remove();

        }

    }

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

You can use either javascript or AppleScript. If you want to compile with Script Editor this Applescript will work:

 

 

tell application "Adobe InDesign CC 2018"
	repeat with x in every document
		tell x
			delete unused swatches
		end tell
	end repeat
end tell

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 04, 2019 Dec 04, 2019

Hi Rob_day,

That worked great..... 

I also just got this one here..

tell application "Adobe InDesign CC 2018"

repeat with i in every document

set active document to i

tell front document

set UnusedSwatches to unused swatches

repeat with UnusedSwatch from 1 to count of UnusedSwatches

try

delete UnusedSwatches

end try

end repeat

end tell

end repeat

end tell

 

Both work well for this...

Thanks everyone!!!!!
Babs 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines