简体   繁体   中英

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 /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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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