Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript Deleted Files via "Make Folder" command

As I was working on an app to transfer photos from my memory card to my computer, I opened a new applescript window to do some testing of the next part of it separate from the main script. I did a simplet "make folder" command to make sure I had the right path. I went to the location I set (my photos library) and one by one, my photo folders started to disappear! This is the code Applescript ran:


tell application "Finder" to make folder in folder "Canon EOS T1i" of folder "Pictures" of folder "Steveporter" of folder "Users" of disk "Macintosh HD" of application "System Events"


The weird part is, ONLY the folders the app made were effected. I have other photos outside of folders that were not deleted, and my iChat Icons folder is still there. I also have the ""Untitled Folder" created by the script.


Does anybody know why in the world that one line in a script would delete my entire photos library? There were no other scripts running, the only apps were Safari and Applescript. I'd also like advice on how I can recover my photos. I downloaded the trial of MacKeeper and it is currently scanning my iMac for recoverable files. Thanks!

iMac, Mac OS X (10.6.8)

Posted on Jul 11, 2012 7:19 PM

Reply
10 replies

Jul 11, 2012 9:13 PM in response to TacosAreDelicious

well, I'm actually surprised that line does anything. the proper syntax for that command is:


tell application "Finder" to make new folder at folder "Canon EOS T1i" of folder "Pictures" of folder "Steveporter" of folder "Users" of disk "Macintosh HD"


in other words, the command is make new folder at, not make folder in, and the of application "System Events" bit at the end is confusingly meaningless. The command does work for some reason, and even works correctly on 10.7, but I have no idea why.


As to why it erased your files... GIGO maybe? Garbage In, Garbage Out - unexpected commands produce unpredictable results. I'm still trying to figure out why it makes it past the error checker.


As an aside, please do at least minimal checking before you download and run software. A quick search on this forum (or even google) would have told you that MacKeeper is suspect: it has questionable value as an app, some slimy advertising aspects, and it is intentionally (IMO) difficult to remove once installed. There's even a long-running debate on whether to consider it a trojan. Hopefully it will recover your files (though there are better apps out there for that purpose), but I suggest you start reading up on how to remove it.

Jul 11, 2012 10:30 PM in response to twtwtw

I wasn't sure about the syntax either, I've seen it work both ways so I assumed it was essentially the same command. I'm still looking around, im past versions of the app it placed the images in some strange locations (my documents folder, desktop, downloads, and the root of Macintosh HD to name a few) but I have not found and images if it had moved them.


As for the "of application "System Events"" I have found that with certain commands, that (or a similar one using Finder in place of System Events) is necessary. I put it on by force of habit.


Thanks for the advice on software, but I actually did know about the bad reviews. I also found that by using certain utilities (in my case CleanMyMac and Quicksilver) all of MacKeeper's files can be removed. Anyways, when it failed to find my missing photos I gave DiskDrill a try (after reading plenty of reviews on multiple different web sites) and that also did not find them. Any other tips for recovery tools I could try?

Jul 12, 2012 1:53 AM in response to TacosAreDelicious

That's surprising. Any files deleted by accident this way would only be deleted superficially (i.e. their file system entries unlinked without touching the file data), so even a low-grade recovery program should have been able to find something. I'm not really up on the best recovery software, but the question comes up here enough that you shold be able to search for it. assuming you didn't add a whole bunch more files to the memory card (which would start overwriting file data), you may be dealing with a failing memory card.


with respect to syntax, you should keep in mind that the 'of' syntax and the 'tell' syntax are parallel. Tell application "Finder" tells applescript that the following material should be owned and handled by the Finder process, and of application "System Events" tells applescript that the preceding material should be owned and handled by the System Events process, so when you use both in a single line like that, it's unclear which of the applications is actally being invoked. The Finder and System events both do file system handling - which may be why it passes error checking - but they do it in slightly different ways with slightly different syntax. You should really never use them together: use the finder for the things the finder does well (moving, copying, deleting and creating file system objects and woking with Finder Windws) and use system events for everything else, and never nest them.

Jul 12, 2012 11:11 AM in response to twtwtw

The files that went missing are actually a series of folders on my startup disk in my Pictures folder. There were about 50GB of data in those folders and I've been careful not to overwrite them by deleting unneeded files that I put on before the photos so anything I do is saved there, not over the photos.


I will definitely keep the "Tell Finder" and "of System Events" in mind, I did not know that putting "of" at the end designated that line to a certain process. I always thought that was necessary to designate that Macintosh HD was of system events (something I found necessary when reading the file size so I used System Events for each time I addressed Mac HD to hopefully avoid potential conflicts when writing and managing files.)

Jul 12, 2012 12:16 PM in response to TacosAreDelicious

Have you run Disk Utility to check if the disk and file system are ok? The only time I ever lost files from an applescript was just after I shifted OSes - I don't remember whether it was when I moved to 10.5 or 10.6. I tried to write to a property list file from System Events and a large chunk of folders simply vanished so that I had to restore them from backups. I'd put that down to some kind of random HFS corruption due to the system upgrade. I ran through the normal disk diagnostics and used Yasu to clear out all the caches and whatnot, and the problem has never resurfaced.


I'm assuming from you recovery attempts that you don't have backups? Backup drives are cheap, data isn't.spend the $150 for a terabyte drive and turn on Time Machine; you'll never know when you'll be glad you did.

Jul 12, 2012 6:51 PM in response to twtwtw

I do have a backup drive but it conveniently failed about 3 days ago. I was planning on upgrading it anyways (it's a cheap WD and I want to replace it with a G-Drive since I've had great experiences with them) so unfortunately my backups are unusable too. I'm in the process of talking with WD, I catually have 3 WD drives that all have the same failed part so I'm seeing if they would be able to recover the data off my main backup given that I probably bought them out of a bad production run. I always use time machine but my drive conveniently decided to die right when I need it!


About OS's though, about a month ago I switched from Lion back to Snow Leopard (doing a full backup and then reformatting my internal drive before doing a clean install of Snow Leopard) so could that have anything to do with it?

Jul 12, 2012 7:12 PM in response to TacosAreDelicious

TacosAreDelicious wrote:


About OS's though, about a month ago I switched from Lion back to Snow Leopard (doing a full backup and then reformatting my internal drive before doing a clean install of Snow Leopard) so could that have anything to do with it?


Well, I couldn't prove it, but it's the possibility that makes most sense to me. I can't think of anything else that would cause folders to disappear in bulk except some kind of file system gremlin, and a new system install is the most likely point at which to get some type of corruption. As I said, run disk utility, clear out everything you can clear out, and the problem shouldn't recurr.


With respect to the multi-drive failures, though, it sounds like the universe is trying to tell you something. 😉

Jul 12, 2012 7:45 PM in response to TacosAreDelicious

I have not heard good things about WD external enclosures. The drive are supposedly OK. Take drive out put in another enclosure.


Stop using the drive immediately.


Get an external drive. I like OWC.


I recommend you do a google search on any external harddrive you are looking at.


I bought a low cost external drive enclosure. When I started having trouble with it, I did a google search and found a lot of complaints about the drive enclosure. I ended up buying a new drive enclosure. On my second go around, I decided to buy a drive enclosure with a good history of working with Macs. The chip set seems to be the key ingredient. The Oxford line of chips seems to be good. I got the Oxford 911.



Has everything interface:

FireWire 800/400 + USB2, + eSATA 'Quad Interface'

&

save a little money interface:

FireWire 400 + USB 2.0

This web page lists both external harddrive types. You may need to scroll to the right to see both.

http://eshop.macsales.com/shop/firewire/1394/USB/EliteAL/eSATA_FW800_FW400_USB


The latest the hard drive enclosures support the newer serial ata drives. The drive and closure that I list supports only older parallel ata.


Here is an external hd enclosure.

http://eshop.macsales.com/item/Other%20World%20Computing/MEFW91UAL1K/


Here is what one contributor recommended:

http://discussions.apple.com/message.jspa?messageID=10452917#10452917


Folks in these Mac forums recommend LaCie, OWC or G-Tech.

Here is a list of recommended drives:

http://discussions.apple.com/thread.jspa?messageID=5564509#5564509


FireWire compared to USB. You will find that FireWire 400 is faster than USB 2.0 when used for a external harddrive connection.

http://en.wikipedia.org/wiki/Universal_Serial_Bus#USB_compared_to_FireWire

http://www23.tomshardware.com/storageexternal.html

---------------------------------------


Here is my list. Your going to need another external drive to recover the data wit these utilities anyway.


Boot in safe mode. Hold down the shift key when powering on the machine. This will run a disk repair program. Boot up will take longer as the harddrive is scanned and repaired.

See this article:

http://docs.info.apple.com/article.html?artnum=107393


Or from mrtotes article :

Boot from the OS X Install disk and from the Menu Bar choose Disk Utility. Then run "Repair Disk" and "Repair Disk Permissions" on your hard disk.


Here the apple article on booting single user mode and using fsck. See the section on Use fsck:

http://docs.info.apple.com/article.html?artnum=106214



Perhaps Disk Warrior will be of some help:

http://www.alsoft.com/DiskWarrior/


"Stellar Phoenix Macintosh - Mac data recovery software, recovers data from damaged, deleted, or corrupted volumes and even from initialized disks."

They have a trial version, so I guess you can see if your data can be recovered...

http://www.stellarinfo.com/mac-data-recovery.htm


"Data Rescue II is the best data recovery software on the market for recovering files from a problem hard drive. Data Rescue II works when other tools fail. Data Rescue II is also completely safe to use since it does not attempt any risky repairs to the drive while its scanning."

http://www.prosofteng.com/products/data_rescue.php


FileSalvage is an extremely powerful Macintosh application for exploring and recovering deleted files from a drive or volume. FileSalvage is designed to restore files that have:

-- been accidentally deleted.

-- become unreadable due to media faults.

-- been stored on a drive before it was re-initialized/formatted.


http://subrosasoft.com/OSXSoftware/index.php?main_page=product_info&products_id= 1


"TestDisk is a free data recovery utility. It was primarily designed to help recover lost data storage partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error (such as accidentally erasing a partition table)."

http://en.wikipedia.org/wiki/TestDisk



-----

"*Hard drive data recovery and warranty implications*


Hard drives that have become non-functional through normal use, and have had data recovery performed on them by DriveSavers or Ontrack Data Recovery can be returned to Apple for warranty service. This includes products covered by the AppleCare Protection Plan. The cost of any data recovery attempts is not covered by the Apple Limited Warranty."

http://support.apple.com/kb/HT3974?viewlocale=en_US



Entering:

mac data recovery

into Google will list some firms who specialize in recovering data. Data recovery isn't cheap.


Examples:

1) Ontrack Data Recovery is the world leader in data recovery services and data recovery software offering the fastest, most convenient and cost-effective solutions to clients who have experienced data loss.

http://www.ontrackdatarecovery.com/


2) Enter the world of DriveSavers Data Recovery…

* Data Recovery Tools

* Data Recovery Process

* Data Recovery Cleanroom

http://www.drivesavers.com/


"Encryption: DriveSavers engineers have been trained and certified by leading encryption vendors, such as GuardianEdge, Utimaco Safeguard, PGP and PointSec, to safely recover file-level and disk-level encrypted data"

http://www.drivesavers.com/recovery-services/encryption/


-------------


List of recovery software tried:

http://discussions.apple.com/post!reply.jspa?messageID=11100707


Robert

Jul 13, 2012 6:53 PM in response to twtwtw

twtwtw,


Ok, hopefully that won't happen again! I'm happy to say that I now have TWO high end G-drives backing up my system! I will never lose data again!




rccharles,


Thanks a lot for all the info! I've been using G-Drives in my studio for a while just because of their speed (I use eSata and that are incredibly fast for single discs!) I already checked out the drives, the burn mark I mentioned is in fact on the back of the disk itself, not any part of the enclosure OR the USB/Power adapter. As for recovering the data, looking back there really is not much I would need. The only thing I will miss is the photos from one night that I didn;t get a chance to post online or print. Everything else is not that important and I have a few photos in the cloud and on my iPad so all is not lost. As for the rest, I'll just chalk it up to experience and remember that any data stored solely on one drive might as well not exist!


Thanks again Robert and twtwtw


Steve

Applescript Deleted Files via "Make Folder" command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.