copy files using robocopy

Roger Roger 5,731 Reputation points
2024-09-02T20:12:05.71+00:00

Hi All

My VM is hosted in Azure. I want to copy a folder (which contains subfolders and files, and some of the subfolder and file names exceed the 255-character limit) from one local drive to another. My local drive is the E drive, and the destination drive is the F drive, which is also a local drive. The purpose of copying the folder to the F drive is to detach this drive and attach it to another VM. I want to use Robocopy because some of the file and folder names exceed 255 characters, even if one file is missed then the application may not work. However, when I execute the command below in PowerShell, I receive an error:

PS C:\windows\system32> ROBOCOPY E:\myfolder F:\myfolder /copy /e

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,705 questions
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,484 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,922 questions
Windows Server Infrastructure
Windows Server Infrastructure
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Infrastructure: A Microsoft solution area focused on providing organizations with a cloud solution that supports their real-world needs and meets evolving regulatory requirements.
535 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,508 questions
{count} votes

Accepted answer
  1. Andreas Baumgarten 107.9K Reputation points MVP
    2024-09-03T05:04:51.9966667+00:00

    Hi @Roger Roger ,

    did you try this already?

    
    robocopy E:\myfolder F:\myfolder /mir /e
    
    

    The reason why your command fails might be because the parameter /copy expects another value: Copy options


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Roger Roger 5,731 Reputation points
    2024-09-03T04:04:01.9233333+00:00

    robocopy

    0 comments No comments

  2. Zunhui Han 1,915 Reputation points Microsoft Vendor
    2024-09-04T14:53:35+00:00

    Hello,

    Thank you for posting in Q&A forum.

    This problem is caused by the wrong parameter options of the robocopy command. I suggest you run the following command:

    robocopy E:\myfolder F:\myfolder /copyall

    User's image

    I recommend you to refer to the following links:

    https://video2.skills-academy.com/en-us/windows-server/administration/windows-commands/robocopy

    I hope the information above is helpful.

    Best regards

    Zunhui

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.