Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I was programming in python and I had two text editors open to the same file, and right before I shut down my computer I saved in the wrong one and overwrote the version I wanted to keep. How can I restore the old version? I'm using Mac OS X Snow Leopard

share|improve this question
1  
Are you using Time Machine? –  Michal M Aug 16 '11 at 15:00
    
Unfortunately, no –  enginefree Aug 16 '11 at 15:01
1  
Unless your text editor has an undo command that works between shutdowns, of which I none which do that, I am pretty sure there is no recovery :( –  hobs Aug 16 '11 at 15:03
2  
How about version control? We all learn this lesson in a personal way. It's not too much to have both version control and an automated backup system. Time Machine is marvelous in it makes hourly snapshots so you lose at most an hours work. Files that have been around for [a day|a week] are saved for [a month|until the drive fills]. It really works well in practice. Sorry to hear you lost work - even software that recovers deleted files won't be of use when another editor truncates the file. It was shredded and not simply deleted. –  bmike Aug 16 '11 at 15:09
add comment

3 Answers

up vote 4 down vote accepted

There is little hope unless one or both of the editors squirrel away copies of the file for you or embed the undo buffer in the document.

It really depends on the editors and the settings.

One last ditch effort is to use the mdfind command. If that file had a memorable string or misspelling you could see in an instant if any files on the disk contain that string. If you search for a common string, you'll have a lot of false positives, but it's worth a shot.

In this case, even software that recovers deleted files won't be of use when another editor truncates the file. It was shredded and not simply deleted


On a personal note, We all learn this lesson about data loss in a personal way, usually many times over.

It's not overkill to have both version control and an automated backup system.

Time Machine is marvelous in it makes hourly snapshots so you lose at most an hours work. Files that have been around for [a day|a week] are saved for [a month|until the drive fills]. It really works well in practice. Sorry to hear you lost work, it's never a good feeling.

share|improve this answer
add comment

You don't mention which editors you were using. My primary editor is BBEdit which has a preference to make backups of every file you save. On my system the files are saved to:

Documents/BBEdit Backups/[Date Folder]/[copies of your files]

This is set via the settings:

BBEdit > Preferences > Text files 

On a side note, I am so paranoid about backup that most of my projects are covered the following:

  • weekly SuperDupper full system bootable backup
  • SVN or Git for the project
  • BBEdit's backup for all text files I touch
  • Home directory Daily offsite incremental backups to Amazon S3 via Arq
  • Home directory every 20 minute backups via Crashplan to system in my office and Crashplan's remote servers
share|improve this answer
add comment

You could try this: http://www.cgsecurity.org/wiki/TestDisk which is free undelete software, although it operates at the command line level. If you are happy with Python I will assume you are familiar enough with the terminal.app.

Other than that, Hope your backup caught the previous file, if you don't have a backup start making one, and/or consider switching to a text editor that provides for revisions/versions/backups etc. Prevention is better than cure, and being proactive with backups is better than being reactive with undeletes. Mistakes happen, I hop you can get your file back one way or another, and think about altering your workflow to try to prevent it happening again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.