Data calculator script for all interfaces

##both must run together first script time is optional second script must be 00:00:00

must reboot after installing the scripts

MIKROTIK-1
#at time 00:03:00 the script runs great 
{ 
:delay 4s
/system logging disable [find where topics="info"]
:foreach i in=[/interface ethernet find ] do={
:global s [/interface get $i name];
:global livedatafeed ([/interface get [find name=$s] rx-byte] + [/interface get [find name=$s] tx-byte]);
:global calculatorram [/file get "$s.txt" contents];
:global Todata [/file get "Totald$s.txt" contents];
:if ($livedatafeed > $calculatorram) do={
:global algo ([$livedatafeed] - [$calculatorram])} else={
/file set "$s" contents="0"
:global algo ([$livedatafeed] - [$calculatorram])}
:global added ([$algo] + [$Todata]);
/file set $s contents="$livedatafeed"
/file set "Totald$s" contents="$added"
:global byTOm ([$added] / "1024" / "1024");
/interface set [find name=$s] comment="######## Total Data = $byTOm MB ########"}
/system logging enable [find where topics="info"]
}

**********************************************************************************************************

MIKROTIK-2
#######set time at device startup 00:00:00

{
:foreach i in=[/interface ethernet find] do={
:local f [/interface get $i name]
:if ([:len [/file find name="$f.txt"]] = 0) do={
/file print file="$f.txt" 
:delay 2s
/file set $f contents="0"
/file print file="Totald$f.txt" 
:delay 2s
/file set "Totald$f.txt" contents="0"
} else={
/file set $f contents="0"
}}}