DEV Community

Cover image for How to Move Files from Your PC to an External Hard Drive Using the Command Prompt
Kelly Okere
Kelly Okere

Posted on

How to Move Files from Your PC to an External Hard Drive Using the Command Prompt

We all have those moments when our computer's hard drive is bursting at the seams, and it's time to move some files to an external hard drive. For me, this scenario recently became a reality. With countless documents, photos, and videos scattered across my C: drive, I needed a fast and efficient way to move them to my external D: drive. While dragging and dropping files in Windows Explorer is convenient, I found a much quicker method using the Command Prompt.

In this article, I’ll share how I used the robocopy command to effortlessly move my files and how you can do the same.

Why I Chose the Command Prompt

When faced with the task of moving large numbers of files, I quickly realized that using the Command Prompt offers several advantages:

  • Speed: It’s much faster, especially when dealing with large directories or numerous files.
  • Precision: I had more control over what was moved, including the ability to include or exclude certain files or folders.
  • Convenience: I could automate the process or save the command for future use, making it easier to manage my files over time.

Getting Started with robocopy

robocopy (short for “Robust File Copy”) is a powerful tool built into Windows. Unlike the basic move command, robocopy is designed to handle complex file operations, making it ideal for my needs.

Example 1: Moving My Documents

Let me walk you through how I moved my Documents folder from the C: drive to my external hard drive (D: drive). Here’s the command I used:

robocopy "C:\Users\HP\Documents" "D:\Backup\Documents" /mov /e
Enter fullscreen mode Exit fullscreen mode

Breaking It Down:

  • "C:\Users\HP\Documents": This was the source directory where all my important documents were stored.
  • "D:\Backup\Documents": This was the destination on my external hard drive where I wanted everything moved. The command automatically created this folder if it didn’t already exist.
  • /mov: This switch ensured that after copying, the files were deleted from the source, freeing up space on my C: drive.
  • /e: This option made sure that all subdirectories, including any empty ones, were moved as well.

Example 2: Moving Only Specific Files

In another instance, I needed to move only my video files from the Videos folder to my external drive. Instead of moving everything, I decided to move just the .mp4 files. Here’s how I did it:

robocopy "C:\Users\HP\Videos" "D:\Backup\Videos" *.mp4 /mov /e
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • *.mp4: This part of the command told robocopy to move only files with the .mp4 extension.
  • Everything else: The rest of the command remained the same as the previous example.

This approach was particularly useful because I didn’t want to clutter my backup drive with other file types like .txt or .jpg.

Example 3: Copying Files While Preserving Their Structure

There was also a time when I wanted to move my entire photo collection but still keep the original directory structure intact on my external drive. The robocopy command made this easy:

robocopy "C:\Users\HP\Pictures" "D:\Backup\Photos" /mov /mir
Enter fullscreen mode Exit fullscreen mode

What’s Different Here?

  • /mir: This switch stands for “mirror” and it copies all files, directories, and subdirectories, creating an exact copy of the source structure in the destination. It also ensures that if I had deleted any files from the source after the initial copy, they would be removed from the destination on subsequent runs of the command.

Running the Command

Once I had my commands ready, all I had to do was hit Enter. The Command Prompt began moving my files, showing me real-time progress. Depending on the number of files, this process could take a few minutes or even longer, but it was significantly faster than using the traditional drag-and-drop method.

Verifying the Move

After the process completed, I always made sure to verify that my files had moved correctly. I did this by navigating to the destination folder on my external hard drive and double-checking that all the files were there. If something didn’t seem right, I could always adjust the command and run it again.

What I Learned

Using the Command Prompt was a game-changer for me. Not only did it save me time, but it also gave me more control over the file transfer process. The ability to customize the command based on my specific needs—whether moving certain file types, preserving directory structures, or ensuring that empty folders were included—made it a valuable tool in my digital toolkit.

Final Thoughts

If you’re like me and find yourself needing to move large amounts of data from your PC to an external drive, I highly recommend giving robocopy a try. It’s a powerful and efficient way to manage your files, and once you get the hang of it, you’ll wonder how you ever managed without it.

So, the next time your hard drive is feeling the strain, open up Command Prompt, and let robocopy do the heavy lifting. You’ll be amazed at how much time you save and how much more organized your files become.

Top comments (0)