-2
I would like to make a batch that does the following count:
Read the source file:
7895537000011
7895537000028
7895537000035
7895537000042
7895537000059
7895537000066
7895537000011
7895537000011
7895537000028
7895537000028
7895537000028
7895537000059
7895537000059
Write like this in a destination file:
7895537000011,3
7895537000028,4
7895537000035,1
7895537000042,1
7895537000059,3
7895537000066,1
Add the repetitions and place in front of the item after a comma. I use to balance items in store. I already managed to make a batch to include ".1" after each barcode 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
)
I need to decrease the size of lines generated by all barcodes and implement a count of occurrences where barcodes repeat.
Thus:
bar code, occurrences
7895537000011,3
So that the total is in front of the code.
How to do this?
And was in doubt about what exactly? Did you make a mistake? Which one? If you didn’t, did you generate the unexpected output? What output did you generate? If you can’t even begin to do it, what do you know about Batch? Please edit the question by answering the relevant questions. As you are new in the community, I recommend you do the [tour].
– Woss
Thanks for the tip, I edited.
– Eder Silva