簡體   English   中英

批處理類型重復行

[英]Batch type duplicates lines

下面的代碼就像圖表一樣工作,除了當我打開目標文件時,每行顯示兩次。 我刪除了目標文件並檢查了很多次。 我沒有運行兩次。

@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

不太了解為什么對所有變量都使用延遲擴展。 但是您可以使用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