TruerWords Logo
Google
 
Web www.truerwords.net

Search TruerWords

Welcome
Sign Up  Log On

“Deleting 'Invisible' Files: Source of Panic and Adrenalin”

From: Seth Dillingham In Response To: Top of Thread.  
Date Posted: Wednesday, November 2, 2005 11:01:28 PM Replies: 2
   
Enclosures: None.

I've been working 12 to 15 hour days on a single project since early Friday morning, last week. This evening, after installing XAMPP on that Windows box I mentioned earlier, I was preparing to move the project over to the server. Before moving it, I wanted to import it to svn.

A preliminary test run with the Windows server had revealed a whole mess of hidden files. Anything I edited in BBEdit had a corresponding hidden file, like surgeons_controller.php and .surgeons_controller.php (or something like that). Before committing it all to svn, I wanted to remove all of the unnecessary hidden files.

It's been a little while since I used the find command, so I was careful. I thought.

find . -name .* -print

Nope, that throws an error. Let's try the regex syntax.

find -E . -regex '^.*/\.[^/]*$' -print

OK, that's better, but it's including the .htaccess files. Need to keep those!

find . -regex '^.*/\.[^/]*$' \( ! -name ".htaccess" \) -print

OK, that looks right. It's listing all of the 'invisible files' except .htaccess. Now I'll just add the command to delete those files.

find -E . -regex '^.*/\.[^/]*$' \( ! -name ".htaccess" \) -exec rm {} \; -print

But wait! Seems like every few weeks I'm having to reconstruct this command. "I'll just make an alias for it in my .bashrc and .bashprofile, so I don't have to work it out like this every time I need to use it..." (Can you hear the dark, scary music playing in the background? It's there.)

Making an alias is easy: just wrap it in quotes and assign it to something, like this:

alias rminv='find -E . -regex '^.*/\.[^/]*$' \( ! -name ".htaccess" \) -exec rm {} \; -print'

Saved the file, opened a new terminal window, cd to the right directory, and run rminv (for "remove invisibles").

WARNING: Don't try that at home, kids! It deleted every single file in my only copy of this project. It was a stupid mistake that I've only just now figured out as I wrote this. Do you see it?

No, I'm not kidding, it really deleted my only copy. I panicked, and asked Brian if he knew of any miracle cures for deleted files. He pointed out a few $100 apps I could try but didn't know of anything free that would do the trick.

I figured file-recovery apps might be cheaper on Windows. I found one called r-undelete that was only $55 and had a free demo. The description suggested that it would let me search for the deleted files, but would only let me recover them after paying fo the app.

Well, it turns out that's not the case at all: it recovers all files less than 64 Kb. That's the limit in the demo version. Plus, it integrates with Windows Explorer very nicely.

r-undelete recovered all but five of my files. One of them was unnecessary, and the other four were views (in the MVC sense) that were very similar to views from another model, so they were quite easy to recreate.

In the end, I wasted about two hours on this. The alternative was unthinkable, though. I still just have the demo to r-undelete, but I will buy a copy soon and I'm hereby recommending it to anyone and everyone.

Now I need a nap. The adrenalin rush from realizing that I had just deleted 60 hours of work has sapped all of my strength!


Discussion Thread:
Trackbacks:

There are no trackbacks.



TruerWords
is Seth Dillingham's
personal web site.
More than the sum of my parts.