Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

One way to avoid keeping DMG files after installation Install
I often find my downloads directory filling with disk images I've downloaded off the internet, installed, and forgotten to delete after unmounting (and possibly rebooting). I'm not sure this qualifies as a hint, but I find the following trick effective to avoid the problem:

While you can't mount an image from the trash using the Finder, you can trash an image once it is already mounted. I won't go into the technical details of why this is true, but the system has no problem keeping track of the actual image's location. So after you open an image to mount it, you can immediately trash it. You can then install and unmount (or reboot) like normal, and forget about the image file altogether, since it's already trashed.

As an alternative, you can mount an image from the trash from the command line. For example:
open ~/.Trash/MyTrashedImage.dmg
And although the Finder will not empty the image from the trash while it is mounted, you can use the command line to remove the image file altogether after it's mounted, bypassing the trash altogether:
rm ~/Downloads/MyMountedImage.dmg
If the image is actually a sparsebundle, this technique should probably be avoided (some will probably work, some will definitely not, and some might have problems if you empty the trash). However, .dmg installers downloaded off the internet should be fine. However, as with any use of rm, be careful what you delete, and make sure you have a current backup!
    •    
  • Currently 2.57 / 5
  You rated: 4 / 5 (7 votes cast)
 
[13,383 views]  

One way to avoid keeping DMG files after installation | 7 comments | Create New Account
Click here to return to the 'One way to avoid keeping DMG files after installation' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One way to avoid keeping DMG files after installation
Authored by: luomat on Jan 11, '08 09:52:42AM

Easier solution:

Move the DMG to /tmp/ before opening it. Then forget about it.

Files in /tmp/ get deleted on reboot.

If you decide you want to keep it, move it back to your Downloads directory or wherever you want it.




[ Reply to This | # ]
One way to avoid keeping DMG files after installation
Authored by: morespace54 on Jan 11, '08 11:17:29AM

Great Idea!

So the cmd whould be:
mv '/Users/MyShortUsername/Path/To/MyDownloaded.dmg' '/private/tmp/'

Obviously, you must replace 'MyShortUserName' with your correct username , replace 'Path/To/' with the correct path to your dmg file and finally replace 'MyDownloaded.dmg' with the correct name of your dmg file.
If you don't use the quotes for the source path and the destination path, just remember to escape the spaces in the paths with backslash! ('\')



[ Reply to This | # ]
Just /tmp
Authored by: SeanAhern on Jan 11, '08 04:13:44PM

You know, you don't have to use /private/tmp. Just /tmp will do. In fact, it's preferred to use /tmp.



[ Reply to This | # ]
One way to avoid keeping DMG files after installation
Authored by: zkarj on Jan 11, '08 12:43:20PM

I go the other way. I keep ALL dmg files.

Every so often I move them to an "Installers" folder, thus keeping the downloads folder clear. Less often I check the total size of the Installers folder and back up to CD/DVD and then clear it.



[ Reply to This | # ]
One way to avoid keeping DMG files after installation
Authored by: krang on Jan 11, '08 01:43:47PM

Or you could use a crontab:

0 20 * * * /Path/To/Script/clean.sh

With something like the following:


if [ -d ~/Downloads/ -a -d ~/Downloads/archive/ ]; then

    find ~/Downloads/* ! -path '*archive*' -mtime +1 -maxdepth 0 -exec mv {} ~/Downloads/archive/ \;

    find ~/Downloads/archive/* -mtime +30 -maxdepth 0 -exec rm -rf {} \;

fi

This will move any files in the ~/Downloads/ folder, to a child folder called "archive" on a daily basis... then after 30 days, delete it.

Although, run at your own risk... its job is to actually delete data.



[ Reply to This | # ]
Whooda thunkit?
Authored by: designbot on Jan 11, '08 02:16:57PM

Wait wait, let me get this straight… if I have files I don't want to keep, I can put them in the trash to get rid of them?

God bless Mac OS X Hints.



[ Reply to This | # ]
Downloads
Authored by: SeanAhern on Jan 11, '08 04:16:10PM

Good luck USING them after you put them in the trash. This hint was about continuing to use DMGs that are in the trash. You know you aren't going to want to use it, so always throw it in the trash, then continue using it.

Personally, I download to the Desktop so everything I download is extremely obvious to me. I also have it sorted by "Last Modified" so DMG downloads appear in the upper right. Can't forget those!



[ Reply to This | # ]