Skip to main content
iBabs2
Inspiring
December 4, 2019
Answered

Remove ALL unused colors from ALL open docs

  • December 4, 2019
  • 2 replies
  • 3284 views

Hello,

 

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

Best,

Babs

Correct answer rob day

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

 

2 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
December 4, 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

 

iBabs2
iBabs2Author
Inspiring
December 4, 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 

xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
December 4, 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();

        }

    }

 

iBabs2
iBabs2Author
Inspiring
December 4, 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 

Community Expert
December 4, 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 )