How to copy one directory to another with window command prompt?
Solution 1
Only sample.txt was copied to folder1
You need to properly specify the target directory name.
Use one of the following commands:
robocopy folder2 folder1\folder2 /COPYALL /E
Or:
xcopy folder2 folder1\folder1 /s
Further Reading
- An A-Z Index of the Windows CMD command line
- A categorized list of Windows CMD commands
- robocopy - Robust File and Folder Copy.
- xcopy - Copy files and/or directory trees to another folder.
Solution 2
xcopy copies only content of folder2 to folder1. You should try this, as now you are under myfolder:
cd folder1
xcopy ..\folder2 folder2 /S /I
Solution 3
Either of the above would work. My preference is to user wildcards, where appropriate.
xcopy /s folder2\* folder1\
Related videos on Youtube
Cataclysm
System.out.println("Hello " + currentViewedUser); while(stillAlive){ if(hasNewTechnology) { learnNewTechnology(myBrain , getLatestTechnology()); } } System.out.print("GoodBye World !"); You can contact me with [email protected]
Updated on September 18, 2022Comments
-
Cataclysm over 1 year
I read alot of guides about to copy directories. On SO also read the posts
- Commmand line command to copy entire directory (including directory folder) to another directory
- copying all contents of folder to another folder using batch file?
but nothing is working for me. I am using Window 10 Pro 64bit version. My directory looks like
myfolder | ---folder1 ---folder2 | ---sample.txt
The expected output is
myfolder | ---folder1 | ---folder2 | ---sample.txt ---folder2 | ---sample.txt
At command prompt, my present working directoy is
C:Users\MyName\Desktop\myfolder>
When I tried with belows
robocopy folder2 folder1 /COPYALL /E xcopy folder2 folder1 /s /i
only sample.txt was copied to folder1. What's I am wrong ?