Skip to content

Instantly share code, notes, and snippets.

@ptts
Last active March 25, 2021 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptts/c252f20d925096ac4e33a940d2abf9eb to your computer and use it in GitHub Desktop.
Save ptts/c252f20d925096ac4e33a940d2abf9eb to your computer and use it in GitHub Desktop.
#!/bin/bash
DATETIME=$(date '+%Y%m%d%H%M%S')
echo "This script will rename the Outlooks database to force a recreation"
read -p "Press enter to continue or close this window to abort."
# Force Outlook Profile rebuild (can take up to an hour)
OUTLOOK_PROFILES_DIR="$HOME/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles"
# Find Mail profile directory
OUTLOOK_MAIN_PROFILE_DIR=""
[ -d "$OUTLOOK_PROFILES_DIR/Main Profile" ] && OUTLOOK_MAIN_PROFILE_DIR="$OUTLOOK_PROFILES_DIR/Main Profile"
[ -d "$OUTLOOK_PROFILES_DIR/MainProfile" ] && OUTLOOK_MAIN_PROFILE_DIR="$OUTLOOK_PROFILES_DIR/MainProfile"
[ -z "$OUTLOOK_MAIN_PROFILE_DIR" ] && echo "** ERROR: Main Profile directory not found. Folders: **" && ls "$OUTLOOK_PROFILES_DIR" && exit 1
if test -f "$OUTLOOK_MAIN_PROFILE_DIR/Data/Outlook.sqlite"; then
NEW_FILENAME="Outlook.sqlite.BACKUP_$DATETIME"
# echo "** Outlook database found. ($OUTLOOK_PROFILES_DIR/Main Profile/Data/Outlook.sqlite) **"
echo "** Renaming file to $NEW_FILENAME... **"
mv "$OUTLOOK_MAIN_PROFILE_DIR/Data/Outlook.sqlite" "$OUTLOOK_MAIN_PROFILE_DIR/Data/$NEW_FILENAME"
echo "** SUCCESS. Now (re)start Outlook and click 'Repair'. **"
else
echo "** ERROR: Outlook.sqlite not found. **"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment