21

Wondering why I lose clipboard data when copying a file. After selecting a string of text and copying it to the clipboard this copied text data is somehow lost if I select a file and copy it in Windows Explorer before pasting the text somewhere.

For example, I select and copy this string of text:

The black dog runs at night

Then I go to Windows Explorer to select and copy a file:

untitled.bat

After this I paste a copy of the untitled.bat file. If I then navigate to somewhere I can paste text (like Notepad), the originally copied string of text is no longer in the clipboard to paste.

Why does Windows do this?

Running Windows10 Pro

6
  • 26
    What do you expect to happen??
    – deep64blue
    Jul 10 at 18:10
  • 16
    Let me clarify: are you aware that Explorer is using the clipboard when you use the Copy and Paste commands? The words copy and paste are only ever used in Windows about the clipboard.
    – trlkly
    Jul 10 at 21:14
  • 4
    @deep64blue I don't expect anything. I'm asking for answers to clarify the behavior of the clipboard as it pertains to txt and files. Jul 10 at 23:57
  • 1
    @trlkly: That's false. The command interpreter aka command.com has a copy command which, like Unixy cp, copies a file. It does not involve the clipboard. You can also right-drag a file in Windows explorer and choose "copy" from the resulting context-menu. That doesn't use the clipboard either.
    – Ben Voigt
    Jul 11 at 19:58
  • 2
    "select and copy a file" - how are you copying and pasting in Windows Explorer? There are multiple ways: keyboard (Ctrl+C, Ctrl+V), context menu (Copy, Paste) and drag'n'drop (hold Ctrl) and potentially more (main menu?) Jul 12 at 9:44

4 Answers 4

25

You don't "lose" clipboard data. It just gets overwritten with new data and by default you can't access old data since it's stored as a single record in RAM. There are better ways to track it, though, one is listed later.

It's because the system can't fully know what exactly you want to paste and there's only single Ctrl + V shortcut for that. Applications can be coded to check for specific formats and handle all of them properly, if needed. So it's up to the user to decide what's the last item. And up to the application to notify the user if the current format is supported, unfortunately a lot of them just do nothing if a paste of unsupported format happens.

Question/answer textboxes on this website are a good example. You can have text (CF_TEXT/CF_UNICODETEXT type) as last item and it'll be pasted as text. You can also have image as last item (CF_DIB type) and it'll upload an image. Or you can have a file copied from Windows Explorer (CF_HDROP type) and pasting that will do nothing, as regular non-image file upload is not welcome here.

To compare, if you compose a mail in let's say Gmail, all of these types will be supported. CF_TEXT will still paste text. CF_DIB will still paste inline image. However, CF_HDROP will be handled better this time and sent as an attachment.

You can read more about types/formats available in Windows here.


You can use advanced clipboard managers like Ditto to get around this limitation:

  • by default, the access to history of items is much easier - through a list you can display and manipulate (e.g. with a shortcut to go to next item) - and you can further configure it if needed
  • you can also configure 3 additional special copy buffers to use for different types of storages. In Options -> Copy Buffers you set 3 key binds for each buffer (separate list): copy, paste and cut. Let's say you define it to be the traditional shortcuts + Shift. Then you can copy all files to the newly defined buffer with Shift + Ctrl + C and your main clipboard will still contain text. This can be helpful for certain workflows.

And on Linux there's CopyQ.

Why do systems themselves not implement multiple buffers? Various reasons that get into "opinion-based" territory, but a fact is that they introduce clutter in terms of extra keyboard shortcuts/buttons if their usage should be comfortable, and cluttering systems of users that don't need this feature wouldn't be great.

2
  • 2
    This was the answer I was looking for. Lots of useful and pertinent info there. Thank you! Jul 10 at 23:59
  • 1
    If I might nitpick myself ... "unfortunately a lot of them just do nothing if a paste of unsupported format happens." Yet another worthless alert message from windows would be the unfortunate thing here, if that were what happens. I think your answer is great, though, a breakdown of Window's inbuilt clipboard history, as Orange Dog and George mention, would be a boon for your answer and the readers.
    – user287352
    Jul 11 at 17:47
41

The clipboard can keep only one item at a time, possibly in one or multiple formats. For example the browser may put the image bitmap, image URL, the website, the alternate text... when you copy an image from some website and the destination app will select the appropriate format when pasting, but it's still just one item. You can check the current formats in the clipboard easily with this

If it can store multiple items then how can the OS know what to paste when you press Ctrl+V? It's the same in almost all OSes. If you copy another thing regardless of the type then the old content will be lost. Imaging copying a file puts the object representing the file, and also put the file path as text into the clipboard, then how can the old text be retained? If a multiple-item clipboard is supported then the sensible behavior when pressing Ctrl+V is to paste the top item, but if some text was put into the clipboard when you copy the file then your previous text already went down the list and can't be pasted


However on Windows there's a built-in clipboard history feature so just enable it and press Win+V. It can even be synced across Windows PCs

Clipboard settings

Clipboard history

6
  • Interesting that my Clipboard History setting is off and grayed out. Jul 10 at 14:41
  • 4
    @RohitGupta corporate machine? This sort of thing can be set in group policy
    – Chris H
    Jul 10 at 15:21
  • 2
    When you select Cut or Copy in File Explorer, the file's name is put on the clipboard, along with a flag saying whether it was marked as Cut or Copy. When you Paste into the target folder, the clipboard is examined, and then file is moved or copied.
    – CSM
    Jul 10 at 16:38
  • 2
    @ChrisH, I am not in a corporate environment. It's on my home PC. Perhaps because I have been using a Clipboard tool that gives history among other functions. Jul 11 at 11:17
  • As another point of information, taking a screenshot also uses the clipboard.
    – Herohtar
    Jul 11 at 17:37
6

The windows clipboard can hold multiple formats, when you copy something the source application will usually place data in the clipboard in multiple formats. The destination application can then choose the "best" format that both applications support. Copying a new item to the clipboard normally replaces the existing content.

When you copy and paste stuff in windows explorer, the windows clipboard is used, but rather than actually moving/copying the whole file to the clipboard it just stores details of the file there, along with whether the user chose a "cut" (move file) or a "copy" (copy file) operation. Then when the user pastes the file in the destination the actual move or copy is performed.

It used to be that if you copied something in another application and pasted it in windows explorer, it would create a "scrap" file containing the contents of the clipboard, but this feature was rarely used and was removed in windows vista.

This leaves windows explorer in the slightly strange position where it uses the system clipboard, but is unable to interoperate with most other applications.

3
  • 2
    "When you copy and paste stuff in windows explorer, the windows clipboard is used[...]" I suspect this is the key part that the OP didn't understand, and which was not made explicit in the other Answers. It can seem odd that the same clipboard that holds text is also used by Exploreṙ to hold files.
    – trlkly
    Jul 10 at 21:10
  • OS/2's Presentation Manager handled this much better - you could copy/paste things about and a piece of image on the clipboard was an image file to the OS at the same time as being an image you could paste into a word processor. Windows Explorer can't do that.
    – Criggie
    Jul 10 at 21:25
  • @trlkly As a user, there's no sensible reason the computer would seem to be confused about the difference between a file and text. As a programmer, it makes sense. Most users aren't programmers, so it's silly this is still the way copy/paste works.
    – user287352
    Jul 11 at 17:54
6

Others have already pointed out the technical reasons that this happens. If you want to observe that yourself, try NirSoft InsideClipboard. It shows you, what is in the Windows clipboard (not the Windows clipboard history). It will contain only one thing you copied but that thing might exist in different formats, like plain text of HTML.

Here's how it may like for your text:

Text copied

After a

  • Ctrl+C or
  • File context menu / Copy
  • Ribbon Copy

in Windows Explorer:

File copied

Solution for this particular issue:

  • Select the file with the mouse and hold it, hit Ctrl for making a copy, move the mouse until you see a copy Icon, indicated by [+], then release the mouse button.
  • use 3rd party tools like FastCopy to copy files.
2
  • 2
    I can remember when Windows used to provide a clipboard viewer (not as featured as this one of course).
    – Neil
    Jul 13 at 2:04
  • Nice answer! Upvoted! Jul 15 at 2:12

You must log in to answer this question.

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