How to separate files in trash?
July 26, 2007 2:15 AM   Subscribe

Any way to separate files in the trash on Mac OS X depending on what drive they're on?

I've erraniously put a large number of files from a removable media in the trash on my Mac OS X-machine. Now the files are mixed with files from the harddisk. Is there any way to separate the removable-media-files from the stationary disk-files? Can I see the filepath in any way?

Thanks!

(Yes, I could unmount the media, empty trash, put media back in and see the files in thrash - but my problem is that I might have trashed duplicates, which now are renamed.)
posted by Rabarberofficer to Computers & Internet (9 answers total) 1 user marked this as a favorite
 
When you move a file that's on a different volume to the trash it actually goes into a trash folder that is in the root directory of that particular volume inside a hidden folder called .Trashes. If you get info on any file in the trash you can see the path name.

So to get it out you just have to navigate to that particular trash folder. But i think you run into another problem where you won't have permissions to view or open the .Trashes folder in the Finder. In which case i think the easiest way is to just log in as the root account, go to Go -> Go to Folder, and type in:/Volumes/NameOfDisk/.Trashes

If you dont have root account enabled the other way is to login to an account with administrator privs then use Terminal to grant yourself permissions to modify the .Trashes folder. In Terminal paste in:

sudo chmod -R 777 /Volumes/'NameOfDisk'/.Trashes

(you need the quote marks in there if there are spaces or funky characters)

Then you type in your password. Now you can select Go->Go to Folder, type in /Volumes/NameOfDisk/.Trashes, browse around and move your stuff out of there.

Disclaimer: I've never done this. I'm on a PC right now. I'm not sure if granting full permissions of a volume's trashes folder will cause the OS X to freak out later. I wouldn't think so, but hey it's just a trash folder. You can always delete it and it'll get recreated.
posted by sammich at 2:49 AM on July 26, 2007


Response by poster: Hi,

Thanks for quick reply. I'm playing around in the Terminal now and try your solution. (Memories of long forgotten nights in the schools computer labs envelopes me...)

How do I put back the permission to the .Trashes when I'm done?
posted by Rabarberofficer at 3:07 AM on July 26, 2007


Best answer: You can also do this without resorting to hacking the system permissions settings:

in TextEdit save the following (as a plain text file) to your home folder (or wherever if you know what you are doing):

#!/bin/bash
for i in *; do
mv $i /path/to/where/you/want/your/files/$i
done

save that in a location that you can find and a name you can identify.

From the terminal (presuming you are comfortable there -- if not, take a deep breath and get there for this excercise):

sudo su -
< enter your login password>
Now you are root.

cd /Volumes/diskInQuestion/.Trashes
sh /path/to/saved/bash/script/from/above.sh

That ought to move all of your trashed files to whatever location you have named.

Good luck.
posted by drfu at 3:09 AM on July 26, 2007


Oh, the files at the new location may be owned by root when you are done - you can reset this in the Finder through Get Info (Select All > Get Info) or in the terminal:

cd /path/where/your/copied/files/are

then

sudo chown yourusername:yourusername *

again, good luck.
posted by drfu at 3:15 AM on July 26, 2007


Response by poster: drfu - that's really neat!

Excellen - thank you!
posted by Rabarberofficer at 3:16 AM on July 26, 2007


Best answer: #!/bin/bash
for i in *; do
mv $i /path/to/where/you/want/your/files/$i
done

That's the same as
$ mv * /path/to/where/you/want/your/files/
posted by cmiller at 4:19 AM on July 26, 2007 [1 favorite]


For the future, get Compost.
posted by bink at 9:29 AM on July 26, 2007


Response by poster: Thanks Bink - will do that. But as they say: It's not until after you needed something, you know that you needed it.
posted by Rabarberofficer at 10:09 AM on July 26, 2007


Best answer: That script is not a good idea. It's not quoted correctly and thus will break if you have spaces in any filenames. And as cmiller noted, it's a convoluted way to use 'mv'. The 'mv' with wildcards shouldn't have any quoting problems though.
posted by chairface at 2:15 PM on July 26, 2007


« Older Help me avoid teevee timesuck   |   3d Modeling for the Autodidact Newer »
This thread is closed to new comments.