![](/img/trans.png)
[英]Windows script batch to copy files from different folders to other folders
[英]Win Batch: copy files on different folders
我有一个bin文件夹,其中包含在调试和发行版本中都构建的dll文件:
myFirstFile.dll
myFirstFiled.dll
mySecondFile.dll
mySecondFiled.dll
...
文件名互不相同,但是规则是在“调试”模式下构建的dll以“ d”结尾。 我无法在.bat脚本中找到将这些文件复制到名为Debug和Release的两个不同文件夹中的方法,以便将以d结尾的dll复制到Debug文件夹中,并将所有其他dll复制到Release文件夹中。
mkdir Debug
mkdir Release
for %a in (*.dll) do if exist %~nad.dll move %~nad.dll Debug
move *.dll Release
您可以使用就地变量编辑来检查文件名的结尾,如以下示例所示:
setlocal enabledelayedexpansion
for %%F in (*.dll) do (
set plainname=%%~nF
if "!plainname:~-1!"=="d" (
move %%F DEBUG
) else (
move %%F RELEASE
)
)
endlocal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.