The other day, someone I know very well (I shall not reveal his identity) called me for some emergency tech support. He had been importing photos from his iPhone to iPhoto on his Mac. A lot of photos. Just over a thousand photos, to be precise. After the import had apparently completed, a message popped up stating that the original photos were being deleted from the iPhone. During this process, iPhoto crashed.

Upon relaunch, all of the supposedly just imported photos were MIA. The photos were similarly gone from the iPhone. Over a thousand pictures, spanning more than 18 months - potentially up in smoke. Time to panic.

That's when my phone rang.

After suggesting that my unnamed caller take a few deep breaths, I offered an initial assessment: "Not to worry. All of your Camera Roll photos are still in your iPhone's iTunes backup. Worst case, restore your iPhone from your backup and the missing photos will return."

The caller responded: "But I don't have any recent backup. I never even connect my iPhone to my Mac. I've been managing everything from the iPhone itself."

"It's great that you are into 'cutting the cord.' Can I then assume you have an iCloud backup? That should also store all your Camera Roll photos and videos."

", I actually never turned on iCloud Backup. So the photos aren't there either."

I briefly contemplated giving a little speech on the importance of backing up. However, I decided this was not the appropriate time. Discretion also indicated that I not mention that importing 1000 photos in one shot was probably not the best strategy. Importing the photos in smaller groups would reduce the chance that iPhoto might choke and crash. And, if a crash did occur, at least only a portion of the photos would be at risk.

Skipping over all of this, I went to my next recovery suggestion: "But you do use iCloud. Right? Do you have Photo Stream enabled?"

A glimmer of a possible solution appeared on the horizon.

"Yes, I use Photo Stream. But it doesn't save videos...and I had a lot of videos. Besides, it doesn't seem to work well for me. There are photos that I took that I never saw in Photo Stream."

Again, now was not the time to get distracted and explore what might be the cause of Photo Stream's apparent failure. I needed to stay focused. I offered some encouragement:

"Well, at least most of your photos are in Photo Stream. That's a start. There's one more thing we can try. It's likely that your iPhoto database got corrupted during the crash. Let's try to rebuild it."

I went on to explain that to do a database rebuild, launch iPhoto while holding down the Command+Option keys. From the window that appears, select the option to "Repair Database." If it works, this should "add photos that are stored in the library but missing from the database." That's exactly what seemed to be going on here, so I was optimistic this would do the trick.

And sure enough, it worked. All the previously missing photos were now visible in iPhoto. Whew! Disaster averted.

If that had failed to work, I had one last option up my sleeve: Try iPhoto Library Manager. This third-party app can also rebuild a corrupted database but works differently than iPhoto's method: "Instead of trying to repair the library in-place, it creates a brand new library and tries to reimport the entire contents of the original library into the new one, including reconstructing albums, photo metadata, etc." Happily, this wasn't needed.

A postscript: iPhoto isn't the only app that brings up a repair function if you hold down the Command+Option (or sometimes just the Option) keys at application launch. For example, the same technique allows you to rebuild or reset the database for Microsoft's Outlook and BusyMac's BusyCal. It similarly opens iTunes in Safe Mode, allowing you to troubleshoot problems with iTunes plug-ins. Bottom line: If you're having trouble with any app, give the Command+Option launch a try. Chances are it will do nothing. But, if you're lucky, you'll be pleasantly surprised.

See also:

Stop drowning in apps

iPhone 6 rumour rollup for the week ending 15 March

Apple fixes Retina MacBook Pro fan speed issue in new update

8 ways to hide files and folders in OS X

Mac troubleshooting: Be prepared for hard-drive failure