Script to Change the Default Application for All .indd Files?

I’m looking for a way to programmatically change the default application for all .indd files on macOS.

Our environment has both Adobe InDesign 2026 and InDesign 2024 installed. I already have a script that can disable InDesign 2026, but if the user doesn’t first use Finder’s Get Info → Open with → Change All… option to associate .indd files with InDesign 2024, the default application ends up becoming InDesign Helper after 2026 is disabled.

To prevent that, I’d like to incorporate a step into my script that automatically changes the default application for all .indd files to InDesign 2024, effectively performing the equivalent of Finder’s Change All… action.

Has anyone done this before or know of a reliable AppleScript, shell command, or other macOS API that can change the default application for a file extension system-wide (or per user)?

Thanks,
-Jeff

Try this:

use framework "Foundation"
use framework "AppKit"
use scripting additions

-- make reference to the 2 versions of InDesign 
set indy2024 to (current application's NSURL's fileURLWithPath:"/Applications/Adobe InDesign 2024/Adobe InDesign 2024.app")
set indy2026 to (current application's NSURL's fileURLWithPath:"/Applications/Adobe InDesign 2026/Adobe InDesign 2026.app")

-- get content type for InDesign document
set thePath to current application's NSTemporaryDirectory()'s stringByAppendingString:("temp.indd")
current application's NSFileManager's defaultManager()'s createFileAtPath:thePath |contents|:(missing value) attributes:(missing value)
set theURL to current application's NSURL's fileURLWithPath:thePath
set {hasResult, theUTType} to theURL's getResourceValue:(reference) forKey:"NSURLContentTypeKey" |error|:(missing value)

-- toggle the default app
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
set indyKey to theWorkspace's URLForApplicationToOpenContentType:theUTType
if indyKey's isEqualTo:indy2024 then set appURL to indy2026
if indyKey's isEqualTo:indy2026 then set appURL to indy2024
theWorkspace's setDefaultApplicationAtURL:appURL toOpenContentType:theUTType completionHandler:(missing value)

-- verification
delay 1
return theWorkspace's URLForApplicationToOpenURL:theURL
1 Like

Thank you so very much, Ionah!

The real breakthrough in your solution wasn’t just using NSWorkspace—I had already gone down that path. The piece I completely overlooked during all of my testing was obtaining the document’s actual Uniform Type Identifier (UTType) from a real .indd document and then calling:

setDefaultApplicationAtURL:toOpenContentType:

using that content type.

I had been approaching the problem from the application side, but your script correctly approaches it from the document type side. By asking macOS which application is assigned to the .indd content type and then changing the handler for that specific UTType, Finder immediately updates the global default application for all InDesign documents.

That ended up being the missing piece that allowed the default application to switch cleanly between InDesign 2024 and 2026 without ever falling back to “InDesign Helper.”

I really appreciate you taking the time to share this solution. It solved a problem that had me scratching my head for quite a while. Thanks again!

-Jeff

1 Like

For my part, I appreciate you taking the time to provide such detailed feedback.
By the way, I’m curious to know why you’re sticking with the 2024 version. I imagine it’s due to some bug?

Good question. We’re not planning to stay on InDesign 2024. My goal is to have everyone proactively install InDesign 2026 so that when we upgrade our InDesign server and officially switch to 2026, they’ll already have it installed and ready to use.

Immediately after installing 2026, operators will run the utility, which will temporarily disable 2026 and keep 2024 enabled. Then, when we’re ready to make the transition, they’ll simply run the utility again to enable 2026 and disable 2024.

I realize this may sound a bit extreme or like overkill, but with so many operators, it’s important to have safeguards in place. Without them, people inevitably end up launching the wrong version. Even if I instructed everyone to manually use Finder’s “Change All” option to make 2024 the default application, some users would inevitably miss that step. This utility provides an extra layer of protection and helps ensure everyone stays on the correct version until we’re ready to flip the switch.

Ok. I thought it was a compatibility issue with some scripts.
Just be aware that scripting environment has changed in InDesign.
There’s a lot of problems. Especially with passing parameters to do script command.

I reported the parameter-passing issue with the “do script” command back in January to the InDesign Developers Prerelease program.

It’s incredible that, to this day, the problem still hasn’t been fixed.

I submitted the same report a few weeks after you.
Some Adobe forum members I know also did.
But nobody’s fooled…

If possible, and if it’s not too much trouble, could either of you provide a short code snippet that demonstrates parameter passing which worked in previous versions of InDesign but no longer executes correctly in InDesign 2026?

Thanks in advance,

-Jeff

Here you are:
(This script should modify the size and position of the selected page item.)

tell application "Adobe InDesign 2025"
	
	set scriptFile to "set {theSel, theAnchor, theMatrix} to arguments
	(transform theSel in parent coordinates from theAnchor with matrix theMatrix)"
	
	set theSel to selection
	set theAnchor to center anchor -- ANct
	set theMatrix to make transformation matrix with properties {horizontal scale factor:1.2, vertical scale factor:1.6, horizontal translation:0, vertical translation:0}
	do script scriptFile undo name "Transform" undo mode fast entire script with arguments {theSel, theAnchor, theMatrix}
	
end tell

Excellent! Thank you very much Jonas!