I need a batch file to get the current date and time of my computer and put it in a text file every time I run it. But I need the most current date&time to replace the previous within the same text file, so that my file can have only one record, even if I run it multiple times.
I found this code:
<codeecho %date% %time% >> log.txt></code>
But this one just adds the next date under the previous one.
You can use the gettime() function in bierscripting to get the current date and time and rename files using that. For example, the following script will rename all files in folder "C:/folder" by appending a timestamp to file names.
# Script AppendTimestamp.txt
var str folder, list, file, extn, name
lf -n "*" $folder ($ftype=="f") > $list
while ($list <> "")
lex "1" $list > $file ; stex -p "^/^l[" $file > $name ; stex "[^.^l" $name > $extn
system rename ("\""+$file+"\"") ("\""+$name+"_"+gettime()+$extn+"\"")
To run the script, copy and paste the script into file C:/Scripts/AppendTimestamp.txt, then enter the following command in biterscripting