hard drive - Why is deleting a file faster than copying?

07
2014-07
  • Maria Meh

    Why it takes more time, say 10 minutes when copying a file But It takes very less time when deleting the same file, it would take 10-20 seconds.

  • Answers
  • AthomSfere

    When you copy a file, every bit or byte must be transferred, or moved.

    For a delete operation all that must be done is mark the header of each cluster as "deleted". The file is intact, it is just hidden from the operating system. This is also why deleted files are so insecure, one just needs to find software that will ignore the header that says the file was deleted and the files can easily be read.

  • Lawrence

    When deleting a file, most Operating Systems will mark the file as deleted, but not actually remove the data from the hard drive. This allows for a fast delete as the OS just has to set one flag and not touch any of the data.

    When copying a file, data actually has to be duplicated in order to copy a file. This means that the OS first has to read the data, and then write it to another spot, which is 2 operations, compared to setting a flag to delete which is just one. The 2 operations also take a lot longer as reading and writing aren't instantaneous.

  • D4NI3LS

    It's because when you delete the file, it just disappears from your view under windows explorer. But actually the file is not going anywhere. It'll be kept there as long as new data is copied to that location. (That's why all recovery softwares are capable of finding deleted files.) But moving/copying a file actually requires lots of process like fetching data from the source and writting the data to a new location. Both these locations may not be consecutive memory locations. A hard drive stores data where a free space is available. So it needs to search for all the contents of source from a distributed area to somewhere a large area of free space is available.

  • Matthew Williams

    A file is made up of a series of attributes like its name, location, access etc etc.

    When you copy a file your system must: first

    1. Create space for the new file
    2. Make a new entry in the directory (record it's location etc)
    3. Read the content of the file to be copied

    This is three steps an OS must follow.

    On the other hand when you delete a file the OS is simply required to search for the named file and remove it.

  • crato

    When you copy a file, the OS must create a new file with the same values as the original. This process of copying a file requires gathering the needed data from the source and then create the new resource with the same values.

    On the other hand, when you delete a file the OS just delete the related link to this file. This process requires less time than the process of copying.


  • Related Question

    hard drive - What is faster cutting or copying a file?
  • Lilitu88

    To get large file from one place to another what is faster cutting or copying a file ? What factors can influence the result?
    I've heard it matters if they are on the same drive and the speed of the drive, but don't know for sure.


  • Related Answers
  • Pär Björklund

    It depends on some factors.

    If you're moving the file on the same drive and partition it will be faster to cut/paste than to copy since it's not actually moving the data.

    If it's across partition or drive boundries it will always be a copy or copy+erase so the difference is minimal.

  • Phoshi

    On the same disk, cutting, by a considerable margin. On different disks, Copying, by virtue of cutting would require the original to be deleted, which would take a tiny amount of time.