3 # This script is only for Office 2016 for Mac.
4 # Tested on Office version 15.16 (151105)
5 # Tested on Office version 15.17 (151206)
6 # Tested on Office version 15.18 (160109)
7 # Use at your own risk.
9 # Some large-sized duplicate files exist in Word.app, Excel.app, PowerPoint.app, Outlook.app and OneNote.app in Office 2016 for Mac.
10 # It's wasting your precious HDD/SSD space as these files are just 5 duplicate copies in these apps.
11 # This script moves some of the duplicate files from Excel, PowerPoint, Outlook and OneNote into a backup directory, and then soft link neccesary paths back to the real files in Word.app alone.
14 # Repo: https://github.com/goodbest/OfficeThinner
17 # Configs. You can change path here
18 basePATH
="/Applications/"
19 backupPATH
="$HOME/Desktop/OfficeThinnerBackup/"
21 WordPATH
="Microsoft Word.app"
22 ExcelPATH
="Microsoft Excel.app"
23 PowerPointPATH
="Microsoft PowerPoint.app"
24 OutlookPATH
="Microsoft Outlook.app"
25 OneNotePATH
="Microsoft OneNote.app"
27 # Symbolic link the files in following 4 apps to Word.app.
28 # If an app's version is not same with Word, it will be excluded.
29 versionPATH
="/Contents/Info.plist"
30 versionKey
="CFBundleShortVersionString"
31 wordVersion
=$
(defaults
read "$basePATH$WordPATH$versionPATH" $versionKey)
33 appPathArrayPending
=( "$ExcelPATH" "$PowerPointPATH" "$OutlookPATH" "$OneNotePATH" )
35 for appPATH
in "${appPathArrayPending[@]}";
37 if [ -d "$basePATH$appPATH" ]; then
38 appVersion
=$
(defaults
read "$basePATH$appPATH$versionPATH" $versionKey)
39 if [ $wordVersion == $appVersion ]; then
40 appPathArray
+=("$appPATH")
42 echo "WARNING: WILL NOT deal with ${appPATH/.app/}. It is version $appVersion, but Word is $wordVersion"
45 echo "WARNING: WILL NOT deal with ${appPATH/.app/}. It is NOT installed."
48 for appPATH
in "${appPathArray[@]}";
50 echo "WILL deal with ${appPATH/.app/}."
53 # If all apps are excluded, just exit the script.
54 if [ ${#appPathArray[@]} -eq 0 ]; then
55 echo "No app will be dealed. Bye"
60 read -n1 -r -p "Do you want to continue? y/n..." key
< /dev
/tty
61 if [ "$key" != 'y' ]; then
62 if [ "$key" != 'Y' ]; then
64 echo "Terminated. Bye"
71 for appPATH
in "${@}";
73 du
-sh "$basePATH$appPATH"
80 echo "Before running this script, Office is taking:"
81 diskUsage
"${appPathArray[@]}"
83 # ==============================
84 # Phase I: Deal with Fonts
85 # Comparison Result: Word = Excel = Powerpoint, Outlook is subset of Word, OneNote is subset of Word
86 # ==============================
87 fontPATH
="/Contents/Resources/"
88 if [ -d "$basePATH$WordPATH$fontPATH/DFonts" ]; then
93 # echo "Thinning Fonts, it saves you ~1.4G space"
94 for appPATH
in "${appPathArray[@]}";
96 appName
=${appPATH/.app/}
97 mkdir
-p "$backupPATH$appName$fontPATH"
98 # echo "$backupPATH$appName$fontPATH"
99 sudo
mv "$basePATH$appPATH$fontPATH$fontName" "$backupPATH$appName$fontPATH"
100 sudo
ln -s "$basePATH$WordPATH$fontPATH$fontName" "$basePATH$appPATH$fontPATH$fontName"
101 # echo "$basePATH$appPATH$fontPATH$fontName" "$backupPATH$appName$fontPATH"
102 # echo "$basePATH$WordPATH$fontPATH$fontName" "$basePATH$appPATH$fontPATH$fontName"
105 # ==============================
106 # Phase II: Deal with Proofing Tools
107 # Comparison Result: Word = Excel = Powerpoint = Outlook, OneNote is subset of Word
108 # ==============================
109 proofingPATH
="/Contents/SharedSupport/"
110 proofingName
="Proofing Tools"
111 # echo "Thinning Proofing Tools, it saves you ~1.5G space"
112 for appPATH
in "${appPathArray[@]}";
114 appName
=${appPATH/.app/}
115 mkdir
-p "$backupPATH$appName$proofingPATH"
116 # echo "$backupPATH$appName$proofingPATH"
117 sudo
mv "$basePATH$appPATH$proofingPATH$proofingName" "$backupPATH$appName$proofingPATH"
118 sudo
ln -s "$basePATH$WordPATH$proofingPATH$proofingName" "$basePATH$appPATH$proofingPATH$proofingName"
119 # echo "$basePATH$appPATH$proofingPATH$proofingName" "$backupPATH$appName$proofingPATH"
120 # echo "$basePATH$WordPATH$proofingPATH$proofingName" "$basePATH$appPATH$proofingPATH$proofingName"
123 # ==============================
124 # Phase III: Deal with MicrosoftOffice.framework
125 # Comparison Result: Word = Excel = Powerpoint = Outlook = OneNote
126 # Maybe it's not a good idea to symbolic link this.
127 # ==============================
128 # frameworkPATH="/Contents/Frameworks/MicrosoftOffice.framework/Versions/A/"
129 # frameworkName="Resources"
130 # echo "Thinning MicrosoftOffice.framework, it saves you ~0.8G space"
131 # for appPATH in "${appPathArray[@]}";
133 # appName=${appPATH/.app/}
134 # mkdir -p "$backupPATH$appName$frameworkPATH"
135 # echo "$backupPATH$appName$frameworkPATH"
136 # sudo mv "$basePATH$appPATH$frameworkPATH$frameworkName" "$backupPATH$appName$frameworkPATH"
137 # sudo ln -s "$basePATH$WordPATH$frameworkPATH$frameworkName" "$basePATH$appPATH$frameworkPATH$frameworkName"
138 # echo "$basePATH$appPATH$frameworkPATH$frameworkName" "$backupPATH$appName$frameworkPATH"
139 # echo "$basePATH$WordPATH$frameworkPATH$frameworkName" "$basePATH$appPATH$frameworkPATH$frameworkName"
143 echo "After running this script, Office is taking:"
144 diskUsage
"${appPathArray[@]}"
146 echo "Office Thinning Complete."
147 echo "The duplicate files are backed up at $backupPATH"
148 echo "If everything is OK, you may delete these files. But the choice is yours."
149 echo "You may have to re-run this script after you install Microsoft Office updates"