CMD命令行:同时将文件复制到多个位置 [英] CMD command line: copy file to multiple locations at the same time

查看:133
本文介绍了CMD命令行:同时将文件复制到多个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CMD命令提示符,使用一行代码大致同时将文件从一个位置复制到多个位置。有没有办法使用COPY / XCOPY等来做到这一点?我无法使用以下类型的命令来完成这项工作:

I am trying to use a CMD command prompt to copy a file from one location to multiple at roughly the same time using one line of code. Is there a way to do this using COPY / XCOPY etc? I haven't been able to get this work using this type of command:

COPY C:\test.txt C:\A1\ C:\A2\

似乎这应该可行,但是错误,即命令语法不正确(复制)或参数数量无效(xcopy)。

It seems like this should work but it gives an error that the syntaxes of the command is incorrect (copy) or invalid number of parameters (xcopy).

任何建议,我们将不胜感激!我想避免使用批处理文件,因为它需要采用这种方式。

Any advice is greatly appreciated! I would like to avoid a batch file because of the way this needs to be implemented.

推荐答案

仅一行代码?丑陋,但可能:

one line of Code only? Ugly, but possible:

for %i in ("c:\A1","c:\my folder","c:\A2") do copy test.txt %i

(如果使用的话)在批处理文件中,将每个%i 替换为 %% i

(if you use it within a batchfile, replace every %i with %%i)

这篇关于CMD命令行:同时将文件复制到多个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆