How To Create Batch File To Copy Files From Folder
- Home
- Programming
- IT Programming
I've been at this for over an hour and I just can't get it right. I've been playing with xcopy.
This is all I need to do.
Copy C:\Test to D:\Test and all it's files and sub folders.
Each time the batch file launches, it should overwrite D:\Test if it exists.
Can someone help me out?
My head hurts.
if not exist D:\test mkdir d:\test
xcopy /e c:\test d:\test
Should do what you need
The help desk software for IT. Free.
Track users' IT needs, easily, and with only the features you need.
8 Replies
Try using powershell to do it using this command
Copy-Item -Path "C:\Test" -Destination "d:\Test" -Recurse
Assuming this is a Windows machine and that you have proper rights for source and destination, here's what I would try (or variant thereof):
xcopy c:\test d:\test /e /h /y
/e will copy folders, even if they are empty.
/h will copy hidden and system files
/y will suppress the prompt to overwrite (necessary when batch copying)
Look at the switch list by typing xcopy /?
Tzo
Try this (if you're wanting to use a batch file):
move C:\Test D:\Test /Y
If you intend to flush the contents of d:\test every time then implement that task as its own line, then run your xcopy as a second line. Don't try to make xcopy do both items, you don't have to
del d:\test\*.* /f /s /q
xcopy c:\test d:\test /s
is there a way to bypass this message? Seems to work file if I press D.
Does C:\Test specify a file name or directory name on the target
(F = file, D = directory)?
if not exist D:\test mkdir d:\test
xcopy /e c:\test d:\test
Should do what you need
you could always just use robocopy to keep them in sync. works well
del %userprofile%\Test\*.* /f /s /q
if not exist %userprofile%\Test mkdir %userprofile%\Test
xcopy C:\Test %userprofile%\Test /e /h /y
This topic has been locked by an administrator and is no longer open for commenting.
To continue this discussion, please ask a new question.
How To Create Batch File To Copy Files From Folder
Source: https://community.spiceworks.com/topic/1433800-need-help-with-a-batch-file-to-copy-one-folder-to-a-new-location
Posted by: mcdonnellturper.blogspot.com

0 Response to "How To Create Batch File To Copy Files From Folder"
Post a Comment