I would like to make a batch that does the following count:
Source file:
7895537000011
7895537000028
7895537000035
7895537000042
7895537000059
7895537000066
7895537000011
7895537000011
7895537000028
7895537000028
7895537000028
7895537000059
7895537000059
Target File:
7895537000011,3
7895537000028,4
7895537000035,1
7895537000042,1
7895537000059,3
7895537000066,1
Add the repetitions and put in front of the item after a comma. I use to balance items in store, thank you to anyone who can help. I was able to do the batch to include ", 1" after each bar code using this code:
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (Inventario_%loja%_%dia%-%mes%-%ano%_%hour%h%min%m%secs%s.inv) do (
echo %%a,1 >>C:\Inventario\Inventario_%loja%_%dia%-%mes%-%ano%_%hour%h%min%m%secs%s\Inventario_%loja%_%dia%-%mes%-%ano%_%hour%h%min%m%secs%s.log
)
But I want to improve it, to decrease the size of lines that is generated by all bar codes, making a count of the same codes and putting the total in front of the code, but I do not know where to start.