How to undo an accidental drag and drop

Short Answer

To undo a file/folder operation in Windows, you can use either the Undo command in the Edit menu, or press Ctrl+Z.

Caveat

NB: There are a few things to note however. While the undo command usually undoes the last file operation, it will not always be the operation you are expecting. Sometimes the last operation does not make it into the undo buffer, making it undo a different operation from what you were expecting. For example, if there are multiple file operations happening at the same time, they are added to the undo buffer in they order that they complete, not the order in which they were initiated. Also, some operations cannot be undone like permanent deletions, those from the command-line, etc.

Recommendation

Instead of using Ctrl+Z, it is safer to use the menu command because you can see what operation Windows will undo before performing it. (Granted, you can redo the operation with Ctrl+Y, but it is easier and safer to just confirm before undoing.) Enable the status bar (View->Status bar), then when you hover the cursor over the Undo command, it will display the operation to be undone.


Screenshot of Windows Explorer with undo command results shown in status bar


Edit > Undo Move or Ctrl+Z. You may have to press Alt first, if the menu bar is not visible.

undo


Ctrl+Z will undo the drag and drop operation. Choosing Undo from the Edit menu works as well.