copying all contents of folder to another folder using batch file?

Started by Hilburn245, December 08, 2020, 12:41:15 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Hilburn245

I have a folder in C:\Folder1

I want to copy all the contents of Folder1 to another location, D:\Folder2

How do I do this using a batch file?

DaveLembke

xcopy c:\folder1\*.* d:\folder2\*.* /s/d/y/h


add the above to notepad and save it as whatever you want it named as such as movedata.bat with .bat file extension and this will copy all contents from c:\folder1 to d:\folder2. Make sure the batch file when run it is not located at c:\folder1 or else you could have an issue due to the file being open. That being said all data that is at c:\folder1 should be not opened by any applications to avoid problems with file in use during copy.

If folder1 and folder2 were just for example purposes but the path is different you can change the instruction to those specific paths; however if your going to target a folder that has files in use you will run into problems!

patio

" Anyone who goes to a psychiatrist should have his head examined. "