InDesign Scripts made to make my life easier.
I've worked in InDesign since 2006 with InDesign Creative Suite. It has been a long time coming that I author scripts to add features I wish were found in InDesign. All of these scripts were generated with help from an LLM.
I find this helpful when testing scripts across multiple open documents. I would run a script, see how it worked, then revert all open documents to test again. This script does the following:
- Check for Open Files: The script first checks if there are any files currently open in the program. If no documents are open, skip to step 6.
- Save File Locations: If there are open files, it makes a list to remember where each file is stored on the computer.
- Go Through Each File: It goes through each open file and adds its location to the list.
- Close All Files: The script then closes all the open files without saving any changes.
- Reopen Files: After closing, it uses the list from step 2 to reopen each file from its saved location.
- Show Message if No Files: If there are no files open at the start, it shows a message saying there are no files to work with.
This script loops through all open documents and saves. I found this helpful while having multiple documents of a book open and wanting to save all open documents.
These scripts compliment the InDesign feature to synchronize styles and Parent Spreads across book documents. While the sync feature will add styles and Parents and update styles and Parents of the same name, it will not remove styles or Parents.
I found that my documents over time and after combining multiple documents from separate projects were very cluttered. For example, for a particular document, I imported a document from word, and it imported about 30 unused and unnamed styles. Other styles were created for one reason or another, renamed in one document but upon syncing added a new style or parent instead of renaming, amongst other situations where the list of styles and parents kept growing.
Scripts that I found online appeared to reduce the number of styles or parents in a document but wouldn't take into consideration styles or parents in use in other documents that a user might want to keep and use later. At first, I would reduce the styles and parents and then resync using the InDesign book feature but would have to sync all documents one at a time to add back all the styles and parents in use across all documents to all other documents.
This set of scripts attempts to address reducing unused styles and parent spreads while taking into account all documents that are open to do it.
This script does a few things:
- Check for Open Files: The script starts by checking if there are any files open in the application. If none are open, skip to 8.
- Prepare to Track Styles: It sets up a way to keep track of which text styles are being used.
- Find Used Text Styles:
- Goes through each open file.
- Within each file, it looks at all the text sections and characters.
- It notes down any text styles that are applied to the characters.
- List Unique Styles: It creates a list of unique text style names that are being used.
- Organize Style Names: The list of style names is sorted alphabetically.
- Notify User: It shows a message to the user with the list of text styles that are in use.
- Remove Unused Styles:
- Goes through each file again.
- For each file, it checks all the text styles.
- It deletes any text style that isn't being used, except for a default style.
- No Files Open: If there are no files open, it informs the user that there are no files to work on.
- Check for Open Documents: checks if there are any open documents in the application. If none are open, skip to 7.
- Collect Used Paragraph Styles:
- Initializes an object to store paragraph styles in use.
- Iterates over each document and its text frames to collect IDs and names of paragraph styles applied to paragraphs.
- Create Unique List of Style Names: Converts the collected paragraph style IDs into an array of unique style names.
- Sort Style Names: Sorts the list of unique paragraph style names alphabetically.
- Alert User: Displays an alert with the list of paragraph style names currently in use.
- Remove Unused Paragraph Styles:
- Iterates over each open document to collect all paragraph style names.
- Identifies which styles are used by comparing them with the list of styles in use.
- Removes paragraph styles from the document that are not in use, except for the "[None]" style.
- Logs an error message if a style cannot be removed.
- Handle No Open Documents:
- If no documents are open, alerts the user that there are no documents to process.
- Check for Open Files: The script starts by checking if there are any files open in the application. If none, skip to 9.
- Prepare to Track Usage: It sets up a way to keep track of which Parent Spreads are being used.
- Identify Used Parent Spreads from Pages:
- Goes through each open file.
- For each page in a file, it checks if a Parent Spread is applied.
- If a Parent Spread is applied, it notes down its details.
- Identify Used Parent Spreads from Other Parent Spreads:
- For each template in a file, it checks if another Parent Spread is applied.
- If another Parent Spread is applied, it notes down its details.
- Create a List of Unique Parent Spread Names:
- Converts the noted details into a list of unique Parent Spread names.
- Organize the List: Sorts the list of Parent Spread names alphabetically.
- Notify the User: Shows a message with the list of Parent Spread names that are being used.
- Remove Unused Parent Spreads:
- Goes through each open file again.
- For each Parent Spread, check if its name is in the list of used Parent Spread names.
- If not found, deletes the Parent Spread.
- Handle No Open Files: If no files are open, it informs the user that there are no files to process.
This script analyzes links in all currently open Adobe InDesign documents.
- Checks for Open Documents: If no documents are open, it alerts the user.
- Collects Link Information: For each document, it gathers data on all links, including how many times each link appears and the pages or master spreads where they are used.
- Creates a Report: Compiles the link information into a CSV file, which can be opened in spreadsheet programs like Excel. The report includes the link's file path, appearance count, and usage pages.
- Saves the Report: The CSV file is saved to the desktop as "link_audit_results.csv".
- Notifies the User: Provides a summary of the total number of links found and the count of unique links via a pop-up message.