如何使用通配符将文件复制到目标?


2

例如,我想将一个shortcut.lnk复制到windows xp中的所有个人用户。因此我想做这样的事情:

echo | f xcopy \\server\networkpath\shortcut.lnk "c:\Documents and Settings\%\Application Data\Microsoft\Internet Explorer\Quick Launch\ /Y /f

如果它在CMD或PowerShell中完成无关紧要,我只需要一些有效的东西。

Answers:


1

您可能最好通过循环目标目录,并将文件复制到每个目录中。 所以有些东西

set sourcefile=%\\server\networkpath\shortcut.lnk%

if exist %sourcefile% (
  for /D %%to in (insert your target path pattern here) do (
    xcopy %sourcefile% %%to
  )
) ELSE (
echo  %sourcefile% not found
)

/ D而不是/ R对引用的目录执行操作,而不是通过它们递归。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.