Get the App
SLTechnology News&Howtos  ›  Development  › 

How to batch bat to add the last column of numbers in the same row of the first column of txt text

Shulou Source: shulou.com Published: 2022-06-03 13:49:32 11月14日 Update

This article mainly introduces how to batch bat text will txt the first column of the same content of the last column of the number added, has a certain reference value, interested friends can refer to, I hope you read this article after a great harvest, the following let Xiaobian take you to understand.

For example, AAA.txt reads as follows

11111,20150430,10

11111,20150430,20

11111,20150430,30

22222,20150430,40

33333,20150430,50

44444,20150430,60

44444,20150430,70

55555,20150430,80

66666,20150430,90

66666,20150430,100

77777,20150430,110

Separate three sections by commas, match the same with the first section, for example, the first row 11111, then the second and third rows are considered to be the same as the first row, and then add the third section values of the same row.

The final results are as follows:

11111,20150430,60

22222,20150430,40

33333,20150430,50

44444,20150430,130

55555,20150430,80

66666,20150430,190

77777,20150430,110

core code

@echo offfor /f "useback tokens=1,2,3 delims=," %%i in ("aaa.txt") do set /a "#%%i#%%j+=%%k"(for /f "tokens=1,2,3 delims=#=" %%i in ('set #') do echo %%i,%%j,%%k)>New_aaa.txt Thank you for reading this article carefully. I hope that Xiaobian will share "How to batch bat to add the last column of the same line of txt text" This article is helpful to everyone. At the same time, I hope everyone will support me more, pay attention to the industry information channel, and more relevant knowledge is waiting for you to learn!

Tags: Same article content number text one line code value interest at the same time numerical value more friends core knowledge results editing industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn macOS Docker Microsoft