Jeff Grunewald

Q: How to Delete files with Terminal?

I tried out Photos as a replacement for iPhoto. It created a 90GB library package file. I don't like Photos and am returning to iPhoto. I tried to put the Photos package file in the Trash, but it was still moving to the trash hours later. I've never trashed a file this large.
I'm not very familiar with Terminal beyond copying and pasting someone else's code into it and I know using it wrong can cause big problems. Is there a way to delete the file more quickly using Terminal?

Posted on Mar 1, 2016 8:16 AM

Close

Q: How to Delete files with Terminal?

  • All replies
  • Helpful answers

  • by JimmyCMPIT,

    JimmyCMPIT JimmyCMPIT Mar 1, 2016 8:27 AM in response to Jeff Grunewald
    Level 5 (6,938 points)
    Mac OS X
    Mar 1, 2016 8:27 AM in response to Jeff Grunewald

    open terminal

    type RM

    type a space

    drag the file on to the terminal window

    the path is added automatically

    press return

     

    however

    it shouldn't take hours to delete a package file unless it has a huge number of smaller files associate with it.

    If your drive is taking this long you may want to check it's integrity with Disk Utility.

    Using Disk Utility to verify or repair disks - Apple Support

    I routinely throw away gig's of data, hosts of image files in subfolders for 3D rendering projects and it should not take more than a few minutes at most. I would cancel the delete and check your disk

     

    also is file vault enabled or some 3rd party tool that keeps, manages or purports to enhances your deletion experience? if so disable FV to test and/or remove the 3rd party software from your system.

  • by Barney-15E,

    Barney-15E Barney-15E Mar 1, 2016 8:25 AM in response to Jeff Grunewald
    Level 8 (49,737 points)
    Mac OS X
    Mar 1, 2016 8:25 AM in response to Jeff Grunewald

    You are wasting your time. It didn't copy all of the photos. It hard linked them. A hard link makes it look like there are two files, but the two "files" are pointing to the same exact storage area.

     

    The the unix command you are looking for is remove (rm). https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/rm.1.html

  • by Jeff Grunewald,

    Jeff Grunewald Jeff Grunewald Mar 1, 2016 8:46 AM in response to Barney-15E
    Level 1 (35 points)
    Mar 1, 2016 8:46 AM in response to Barney-15E

    I tried both rm and unlink and Terminal returned this both times: "/Photos Library.photoslibrary: is a directory"

    and didn't delete it.
    The question is, is it really 92gb or is it pointing just to the 100.77gb iPhoto library it came from and showing 92.16gb

  • by Barney-15E,

    Barney-15E Barney-15E Mar 1, 2016 8:52 AM in response to Jeff Grunewald
    Level 8 (49,737 points)
    Mac OS X
    Mar 1, 2016 8:52 AM in response to Jeff Grunewald

    You have to enter the correct syntax for a directory as shown in the man page I linked.

    Remove cannot delete a non-empty directory so you have to recursively delete the contents spusing the -R option

     

    It depends on what your definition of "real" is. As for the storage space consumed, it is only using up the space necessary for the original files in the iPhoto library.

  • by Luis Sequeira1,

    Luis Sequeira1 Luis Sequeira1 Mar 1, 2016 9:17 AM in response to Jeff Grunewald
    Level 6 (11,824 points)
    Mar 1, 2016 9:17 AM in response to Jeff Grunewald

    Jeff Grunewald wrote:

     

    I tried both rm and unlink and Terminal returned this both times: "/Photos Library.photoslibrary: is a directory"

    and didn't delete it.
    The question is, is it really 92gb or is it pointing just to the 100.77gb iPhoto library it came from and showing 92.16gb

     

    Using a command such as "rm" in the Terminal is not something I would advise to anyone who has to ask about it.

    It is like putting a chainsaw in inexperienced hands. This can cause irreparable damage if you make one tiny mistake, with no Command-Z to undo it.

     

    When Photos creates a library from an existing iPhoto library, the files are not duplicated, as Barney explained. So by keeping the Photos library you are not wasting GB of space (and, therefore, you are also not gaining that much space by deleting it).