Windows environment :
I am having some difficulties with doing what I expected to be rather simple. I have for the past 2 hours been unable to copy a directory and its files and sub-directories to another location.
eg: I have Directory MyDir with files 01.txt 02.txt and a Sub-Directory MyDir2 with files sd01.txt inside it.
I have been trying to use the commands ROBOCOPY as well as XCOPY. Here are 2 examples of the commands I have tried.
>ROBOCOPY /MIR MyDir temp
>ROBOCOPY /MIR /CREATE MyDir temp
What happens is the only the files and directories that are inside of MyDir are being copied.
What I want is for the folder MyDir itself to be copied to temp.
What is incorrect about my syntax?
For XCOPY this would do the job:
xcopy mydir temp\mydir /s /i
If mydir
is missing below temp
it will be created as a directory ( /i
). /s
copies subdirectories
You might want to mix any of the parameters xcopy offers, for example /e
, /k
- but this depends on what exactly you need to do besides copying the directory structure and files.
Using temp\\mydir
as the target will work for robocopy too:
robocopy /mir /create mydir temp\mydir
Tried both commands here and they worked for me.
xcopy DIRSOURCE DIRDESTINATION /s /e /h
DIRSOURCE = the path to the directory being copied
DIRDESTINATION = the path to where you would like to copy DIRSOURCE
/s : Copies directories and subdirectories, unless they are empty
/e : Copies all subdirectories, even if they are empty
/h : Copies files with hidden and system file attributes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.