xcopy - 将文件从包含目录复制到文件夹拖动的目录

xcopy - copy files from the containing directory to directories on folder drag

我有一个 .bat 文件位于包含许多资源 .resx 文件的目录中。

当我将文件夹拖到 .bat 文件时,我希望能够复制以所需文本开头的文件(例如 Web.de.resx、Web.fr.resx 等),在该目录中,到所需文件夹中的相应目录。

我尝试了以下方法,但出现错误:File not found - Web*

xcopy /i "Web*" "%~1\src\Resources\web"

您需要指定 .bat 应在其中查找 Web* 文件的目录。

你可以通过使用"magical" %~dp0变量来做到这一点,~d是驱动器,~p是你被执行的路径(没有驱动器),所以,~dp将成为驱动器和路径。

xcopy /i "%~dp0\Web*" "%~1\src\Resources\web" 一起工作应该会更好。