Skip to main content
iBabs2
Inspiring
Dec 4, 2019 4:57 PM UTC
Answered

Remove ALL unused colors from ALL open docs

Hello,

 

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

Best,

Babs

rob day
rob dayCorrect answer
Community Expert
Dec 4, 2019 10:01 PM UTC

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

 

9 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
Dec 4, 2019 10:01 PM UTC

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
iBabs2
iBabs2Author
Inspiring
Dec 4, 2019 10:34 PM UTC

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
xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
Dec 4, 2019 8:21 PM UTC

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
iBabs2
iBabs2Author
Inspiring
Dec 4, 2019 8:29 PM UTC

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
Community Expert
Dec 4, 2019 9:23 PM UTC

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