Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is there any way to copy a folder and its contents from one from one directory to another? Xcopy c:\myfile1 f:\myfile2 will only copy the contents of myfile1 to myfile2. I'd like myfile1 to be a subfolder of myfile2 as part of the copy. Is there a way for me to do that?
Thanks..

try a trailing backslash to final destination.
Instead of xcopy C:\myfile1 F:\myfile2
try xcopy C:\myfile1 F:\myfile2\Everyone wants a faster PC

Thanks for the response. Unfortunately, doing the xcopy with the trailing backslash still only copies the contents of the source folder.
Dave

xcopy uses the /s (sub-directories) switch.
type xcopy /? for its use
should be xcopy C:\myfile1 F:\myfile2 /s

/s does copy the subdirectories to myfile2, but I want to copy the whole myfile1 source folder to myfile2. So in the end, myfile2 would have a subfolder called myfile1 in it.
Dave

xcopy c:\myfile1 f:\myfile2\myfile1 /e /i
Expert: someone who reads the manual when no-one's looking

That'll work! Is it possible to write a batch file routine that will compare the files in source (a) and destination (b) directories, add files from a that aren't in b, and overwrite files in b that match files in a, and delete the files in b that aren't in a? Xcopy seems to be able to do all of the above except delete the files in the destination (b) that aren't in the source (a). I guess I could run a delete routine: del f:\myfile2 *.* before running the xcopy routine.
Dave

Should indeed be possible. The problem you had with XCOPY is that it copies the CONTENTS of a directory (folder - ugh!), so you have to put the directory name in the destination path. That unfortunately results in XCOPY asking whether the destination is a file or folder, which is where the /I switch comes in. I just added the /E for completeness, in case there are any subdirectictories of the source. I assume you know that <command>/? gives help for command parameters?
Expert: someone who reads the manual when no-one's looking

how can i get to My Documents if it is in " C:\Documents and Settings\Vish.Home\My Documents " ????
Please Help me.
Help me save My Documents using DOS.

In a batch file, "%userprofile%\My Documents" (including quotes) references the current user's folder.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |