简体   繁体   English

批处理类型重复行

[英]Batch type duplicates lines

Below code works like a chart except that when I open the target file each line appears typed twice! 下面的代码就像图表一样工作,除了当我打开目标文件时,每行显示两次。 I deleted the target file and checked many times. 我删除了目标文件并检查了很多次。 I'm not running it twice. 我没有运行两次。

@echo off
setlocal enableDelayedExpansion
set "sourcelocation=\\whatever\Outbox\"
set targetlocation="G:\whatever\SharedData\\"
set "tmplocation=C:\tmpmerges\\"
set refdate=20151113
set versionID=000001
set entity=WTV
echo ...merging files
for %%f in (!tmplocation!*_WTVS_*!refdate!*_V!versionID!.txt) do type "%%f" >> !tmplocation!S_!entity!_WTVS_!refdate!_V!versionID!.txt
echo file merge completed
pause

Not really understanding why you are using delayed expansion for all your variables. 不太了解为什么对所有变量都使用延迟扩展。 But you can try this with your FOR command. 但是您可以使用FOR命令尝试此操作。

for /F "delims=" %%f in ('dir /a-d /b "!tmplocation!*_WTVS_*!refdate!*_V!versionID!.txt"') do type "%%~f" >> !tmplocation!S_!entity!_WTVS_!refdate!_V!versionID!.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM