Deleted by mistake files, recovery script needed

Hello everyone,

I am coming to you with a very troublesome question today…

I by mistake ran a script that deleted some of my files located on an external drive. When I realised that I was erasing my files I unplugged the HDD and closed the computer to make sure the script stopped.

For most of my folders and files they are on the HDD but a small chunk is gone…

Does anyone have a script handy to recover these files?

Kind regards,

Much depends on how you performed the delete operation.

If you used Finder, the files SHOULD be in the Trash. Finder should be able to see the volume’s trash when it is plugged in.

If you used some form of do shell script in your script to perform the deletions, you are probably out of luck.

Hello Craig,

Hum bad news then as I did a shell script…

I googled and found some apps that can recover deleted files or partitions but it is expensive…

Can anyone recommend a tool?

Thanks,

Hello Claude

I got good results with Data Rescue.

CAUTION
As you are wanting to revive documents already erased, DON’T WORK WITH THE HARD DISK WHICH WAS STORING THE DOCUMENTS.
The blocks allocated to the documents are marked as free so the system is allowed to write upon them.
If you buy a tool like Data Rescue, don’t install it on the disk storing the documents. For the reason given above, it would be a very efficient way to kill definitively the docs contents.

If you are running an OS offering AutoSave and Versions, I may send you a set of three scripts allowing us to extract datas stored by Versions. I know that if the main document is deleted with the Finder the system remove the related versions but I don’t know if it’s the same when we delete with a shell script.

I know that you have my mail address so no need to give it here.

Yvan KOENIG (VALLAURIS, France) lundi 20 octobre 2014 11:36:02

Hello Yvan,

Thank you for the information I’ll take a look at Data Rescue then…

Kind regards,

Just for the record: The autosave and versions are presented as part of the operating system but it is part of the improved NSDocument object since Lion. It’s not that there are different versions of the file stored on your disk. There is a database containing all the changes that has been made since the last version. Therefore you can only browse versions through the file inside the application itself that supports the data type.

The autosave feature will, like time machine, update every hour the state of the currently opened files. I think (I have no source) that includes cleaning up the autosave/version database when there are orphaned records in there.

I apologize but you are wrong.

I allowed numerous users to extract their iWork documents when the application prove unable to open them due to several kind of corruption.
To do that I wrote three scripts.
If you are interested you may send a mail to my mailbox :
k o e n i g . y v a n @ s f r . f r
I would be glad to send you the three beasts.

It’s just a pity that Apple doesn’t offer a Graphical Interface to such feature.

Yvan KOENIG (VALLAURIS, France) lundi 20 octobre 2014 19:14:38

Yvan is correct: there are separate versions stored. Run this in Yosemite and choose a document that you know is open with unsaved changes (or configure it as a script library if you’re on Mavericks):

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set theFile to choose file
set anNSURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of theFile)
((current application's NSFileVersion's otherVersionsOfItemAtURL:anNSURL)'s valueForKeyPath:"URL.path") as list

It returns all but the current version.

Hello Shane

What is really important from my point of view is that we may extract versions of documents which are no longer openable by the application which created them.
The point about which I have no answer at this time ” I plan to make tests when I will have time available (we may dream) ” is if we may extract versions of documents deleted thru System Events or thru do shell script.
I assume that if somebody erase a file with these tools, he may duplicate immediately the .DocumentRevisions-V100 hidden folder which contain the versions.
Doing that we may hope that the embedded versions aren’t already deleted.
At this time, I only allowed several despaired users to revive corrupted iWork documents when the corrupted files were available. The worst case was a Pages document whose visible file was containing a huge flow of $00 bytes.
For me, extracting a valid version was just routine but for the user it was a kind of miracle.

I’m really puzzled by the way users misunderstand what Versions does.
I assumed that if I was able to understand what Apple wrote ” just what was published for standard users, no developper’s resources ” everybody may do the same.
In fact, I was wrong and it was a conflict about that which was the origin of by ban from Apple Discussions Forums.

Yvan KOENIG (VALLAURIS, France) mardi 21 octobre 2014 11:04:12