windows 如何使用批处理文件复制文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8574675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:02:33  来源:igfitidea点击:

How to copy files using a batch file?

windowsbatch-filecopy

提问by PD24

I need to create a batch file to copy certain files (e.g., 19_1_White.jpg) to a folder within the directory. How can I do this?

我需要创建一个批处理文件来将某些文件(例如,19_1_White.jpg)复制到目录中的一个文件夹中。我怎样才能做到这一点?

回答by Spikey21

XCOPY F:\*.* G:\ /C /S /D /Y /I

XCOPY allows for copying of files, directories, and sub directories.
F:\*.* is our source location
G:\ is our destination location
/C tells XCOPY to ignore errors, and finish what can be done
/S tells XCOPY to copy everything including directories and
subdirectories
/D tells XCOPY to only copy source files that are newer than the
destination files (big time saver on the process)
/Y tells XCOPY to overwrite files without asking for confirmation
/I tells XCOPY to automatically create new directories on the
destination, if new directories were created in source.

回答by Sachin Kainth

you need to use the command XCOPY eg XCOPY A.jpg C:\Folder\A.jpg

你需要使用命令 XCOPY 例如 XCOPY A.jpg C:\Folder\A.jpg

Take a look at https://support.microsoft.com/en-us/help/289483/switches-that-you-can-use-with-xcopy-and-xcopy32-commandsfor any other switches you may want to use too.

查看https://support.microsoft.com/en-us/help/289483/switches-that-you-can-use-with-xcopy-and-xcopy32-commands了解您可能想要使用的任何其他开关也。