Deleting unused styles

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
Post Reply
Jean-Marie Schwartz
Posts: 1174
Joined: 23 Nov 2004, 04:30

Deleting unused styles

Post by Jean-Marie Schwartz » 03 Jan 2013, 06:13

Hi all! Here is a script that'll delete every unused para and char style sheet and delete every non-default color. HTH.
(Note that the Satimage.osax is required for sorting the lists in the handlers.)
property DefaultColors : {0, 1, 5, 6, 7, 8} -- these are the uniqueID of the default colors of Quark (I might have deleted RGB a while ago though so if you do have RGB colors as default you should add 2, 3, 4 in this list)

tell application "QuarkXPress95"
tell document 1
-- COLORS -> comment the relative lines if you don't want to delete colors
-- NOTE: if you fear some non-default color are used in some used objects or style sheets, you can modify the script in order to get name of color of every generic box, etc.
set TheColors to every color spec
-- FIRST we stock the styles both existing and used
set ListeStylesParagraphes to name of every style spec
[b]set ListeStylesCaracteres [b]to name [b]of [b]every character spec
[b]set StylesParagraphesUtilises [b]to [b]my GetUsedParaStyles()
[b]set StylesCaracteresUtilises [b]to [b]my GetUsedCharStyles()
-- THEN we delete any unused style
-- deleting style spec (paragraph style sheets)
[b]repeat [b]with i [b]from 1 [b]to (length [b]of ListeStylesParagraphes)
[b]if item i [b]of ListeStylesParagraphes [b]is not [b]in StylesParagraphesUtilises [b]then
trydelete style spec (item i of ListeStylesParagraphes)end tryend ifend repeat-- deleting character spec (character style sheets)repeat with i from 1 to (length of ListeStylesCaracteres)if item i of ListeStylesCaracteres is not in StylesCaracteresUtilises thentrydelete character spec (item i of ListeStylesCaracteres)end tryend ifend repeat-- and deleting colors -> comment the following lines if you don't want to delete colorsrepeat with AColor in TheColorsif uniqueID of AColor is not in DefaultColors thendelete AColorend ifend repeatmy Bip(2)end tellend tellon GetUsedParaStyles()tell application "QuarkXPress95"telldocument 1set TheStyles to name of style sheet of every paragraph of every storyset TheStyles to my SortMyList(TheStyles)return TheStylesend tellend tellend GetUsedParaStyleson GetUsedCharStyles()tell application "QuarkXPress95"telldocument 1set TheCharStyles to name of character style of every text style range of every storyset TheCharStyles to my SortMyList(TheCharStyles)return TheCharStylesend tellend tellend GetUsedCharStyleson SortMyList(TheList)set TheSortedList to sortlist TheList with remove duplicatesreturn TheSortedListend SortMyListon Bip(x)beep xend Bip

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”