Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am curious to know how computers execute "copy" and "paste" of large folders. I've read that copy and paste of text between different processes or same process is achieved by saving the content into RAM and then copying it from there to destined location.

So, how does computer instructions flow while copying a folder of say 10 GB on a machine which has 2 GB RAM and 4 GB max virtual memory. Is file copy is different from text copy.

I think it's basic question but any links or insights appreciated.

share|improve this question
The clipboard doesn't actually contain the contents of the folder, just the folder's location. – Dennis Feb 27 '13 at 16:20
So, there is no memory usage for this copy instruction? And do have any idea how this instruction works. Does it run as background process and how does computer check the status of this copy task. – Sundeep Feb 27 '13 at 16:26
I think it would also depend on the OS. Is your question specifically about Windows? – Brad Patton Feb 27 '13 at 16:35
Copying a file can be done with a fixed amount of RAM: 1. Read, e.g., 1 MB from the source file. 2. Write to the destination file. 3. Repeat. The copying process is handled, by default, by Windows Explorer. – Dennis Feb 27 '13 at 16:38
Intention is to know about memory allocation and command execution. Working of it in Windows OS is fine. – Sundeep Feb 27 '13 at 16:39
up vote 4 down vote accepted

Clipboard doesn't have to hold entire file. When you copy a file (or files), only its path is put into the clipboard. It's also marked as a file - clipboard keeps track of its content's type, like plain text, formatted text, file, image, Word text etc. This is why you can't for example open up an image in Paint, press Ctrl+C and then paste it into a directory - because you have copied a picture, and directories hold files, not pictures.

When you paste a compatible content (i.e. file(s) and/or folder(s)) into a directory, some application will handle the copying/moving operation. By default it will be the explorer process (the same one that's responsible for displaying Start menu and all file explorer windows), but some apps may replace it.[1]

What happens now depends on what you're doing:

  • If you're moving a file to another directory on the same partition, it won't be physically moved on the disk, only its path will be updated[2].
  • If you're moving a file to another partition, it will be split into chunks of the same size[3] and those will be copied one by one, then the original file will be deleted. Too small chunks will slow down the process, too big chunks will consume more memory.
  • Exactly the same will happen when you're copying a file (no matter if it's the same partition or not), except that the original file won't be deleted.
  • Writing to an external storage (like USB drives) doesn't work exactly like that[4] and I'm not sure what exactly happens then. My guess is that it's not a continuous chunk-by-chunk process, but something else happens every few chunks (buffer-related?). If anybody knows something about this, then feel free to edit.


[1]. For example TeraCopy, which is a nice advanced copy window replacement.

[2]. Physical file structure on the hard disk doesn't resemble the directory structure - it's flat and all hierarchy information is stored in a separate part of the partition. How it's exactly done depends on filesystem (for example see MFT). That information block holds all the information about file locations etc. So when you move a file inside one partition, there's no need to move it physically - only the path information has to be updated.

[3]. Not literally, nothing will be split on the hard disk. The program that handles the copying process will work like there are multiple separate chunks, but the original file will be untouched. It's purely virtual.

[4]. You can see it when using TeraCopy: the "predicted progress" doesn't work like on fixed drives, instead the "real progress" catches up with it, then "predicted progress" is expanded and so on. Explorer's default copy window has USB hiccups too.

share|improve this answer
"This is why you can't for example open up an image in Paint, press Ctrl+C and then paste it into a directory - because you have copied a picture, and directories hold files, not pictures." You can with Directory Opus. But your point stands. – Mavromatis Lozay Feb 27 '13 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .