Overwrite file contents. Batch File

时间:2015-07-28 16:53:32

标签: batch-file cmd scripting

I have a batch file, and i need to move a folder from one directory to another. I can do that no problem. But, im hitting a problem after that.

The folder i just moved is created at run time, then moved to the final destination folder where it needs to remain, unless the user decides to delete it.

So, if the user runs the batch file a second time, when it tries to move the run time folder, there is already the old version of the folder at the destination and it gives a "permission denied" error.

So my question is, what is the best way to overwrite the contents of a folder from a batch file?

Right now i am just using the move command. Which works fine for overwriting regular files, but it cannot overwrite folders apparently.

Thanks.

1 个答案:

答案 0 :(得分:0)

Would suggest to use either xcopy or robocopy for Overwriting folders

Xcopy /E /Y会覆盖文件夹,

请找到更多选项Xcopy /?

请注意,我提到这个选项只是为了覆盖而不是移动文件夹。