Over a year ago, I posted a script that updated all the icons in a user’s Dock that were pointing to Office v.X apps to Office 2004 apps. That script doesn’t really work under Tiger, because the default plist format has changed in Tiger from XML to binary.
Fortunately, the fix is pretty easy. You can use a utility called “plutil” to convert to/from XML and binary formats:
/usr/bin/plutil -convert xml1 "$homedir/Library/Preferences/com.apple.dock.plist"
Here’s a script that updates Photoshop CS and ImageReady CS dock items to their CS2 counterparts:
#!/usr/bin/perl
# This script edits com.apple.dock.plist
# to remove Adobe Photoshop CS entries and replace them with
# Adobe Photoshop CS2 entries.
#
#
# by Greg Neagle, gregneagle@mac.com, Jan 2006
$homedir = $ENV{'HOME'};
# is Photoshop CS2 installed?
if (-d "/Applications/Adobe Photoshop CS2") {
# has this script done its thing?
if (!(-e "$homedir/Library/Preferences/com.apple.dock.plist.pscs")) {
# convert plist to xml format
`/usr/bin/plutil -convert xml1 "$homedir/Library/Preferences/com.apple.dock.plist"`;
open DOCKPREFS, "$homedir/Library/Preferences/com.apple.dock.plist"
or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist");
open DOCKOUTPUT, ">$homedir/Library/Preferences/com.apple.dock.plist.new"
or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist.new for output");
until (eof DOCKPREFS) {
$text = readline(DOCKPREFS);
print DOCKOUTPUT "$text";
if ($text =~ "file-data") {
$dictBlock = "";
$officeAppFound = 0;
while(!($text =~ "")) {
$text = readline(DOCKPREFS);
if ($text =~ "/Applications/Adobe Photoshop CS/Adobe ImageReady CS.app") {
# replace the path
$text =~ s|Adobe Photoshop CS/Adobe ImageReady CS.app|Adobe Photoshop CS2/Adobe ImageReady CS2.app|;
$psAppFound = 1;
} elsif ($text =~ "/Applications/Adobe Photoshop CS/Adobe Photoshop CS.app") {
# replace the path
$text =~ s|Adobe Photoshop CS/Adobe Photoshop CS.app|Adobe Photoshop CS2/Adobe Photoshop CS2.app|;
$psAppFound = 1;
}
$dictBlock = $dictBlock . $text;
}
if ($psAppFound) {
# get rid of the _CFURLAliasData block
$dictBlock =~ s|_CFURLAliasData.*||s
}
print DOCKOUTPUT "$dictBlock";
}
}
close (DOCKOUTPUT);
close (DOCKPREFS);
#rename our files
`mv $homedir/Library/Preferences/com.apple.dock.plist $homedir/Library/Preferences/com.apple.dock.plist.pscs` ;
`mv $homedir/Library/Preferences/com.apple.dock.plist.new $homedir/Library/Preferences/com.apple.dock.plist` ;
# restart the Dock
`killall Dock`;
}
}
#END