Hi guys,
I am new to Powershell and not sure if this would work or even if this is at all possible.
I have a <g class="gr_ gr_161 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del" data-gr-id="161" id="161">txt</g> file called lids400.txt which can contain many rows of numerical data in 1 column;
ie
column 1
500
400
900
1000
What <g class="gr_ gr_659 gr-alert gr_tiny gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling multiReplace" data-gr-id="659" id="659">i</g> am trying to do is
1) sum the contents of the column 1 data. ie. =2800
2) divide the sum ie 2800 by 20 = 1850
3) create a new text file called total_lids_txt containing the following data
assign the word lids400 = column 1
add the result of <g class="gr_ gr_3922 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Grammar only-del replaceWithoutSep gr-progress" data-gr-id="3922" id="3922">the step</g> 2 = column 2
Add today`s date dd/mm/<g class="gr_ gr_1716 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling" data-gr-id="1716" id="1716">yyyy</g> hh:mm = Column 3
Thus the output in the text file called: total_lids_txt
Lids440; 1850; 19/03/2018 HH:MM
I have the following bit of code which I had cobbled together in a bat file, but it seems that everybody recommends using <g class="gr_ gr_4418 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="4418" id="4418">powershell</g> instead of bat files!
@echo off
for /f "tokens=1 delims= " %%i in (lids400.txt) do (set /a sum+=%%i)
echo %TIME%
set datetimef=%date:~-4%/%date:~3,2%/%date:~0,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
echo %datetimef%)
echo lids400; %sum%; %datetimef%> total_lids_txt
endlocal
this works up to a point, ie, sums the column data and outputs the following lids400;2800; 19/03/2018 09:30, into a <g class="gr_ gr_5161 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del" data-gr-id="5161" id="5161">txt</g> file called total_lids_txt, but I am not sure how to add a divide function into the code;
Question
How could I add a divide function so that the sum (result) is divided by 20 and is this something which can be done in Powershell or should I try and figure out how to do this in a bat file?
Thanks for any help in advance
Roger