Skip to content

Instantly share code, notes, and snippets.

@oshinko
Created July 10, 2021 03:53
Show Gist options
  • Save oshinko/cfe3f54657911001be60ed675de44d58 to your computer and use it in GitHub Desktop.
Save oshinko/cfe3f54657911001be60ed675de44d58 to your computer and use it in GitHub Desktop.
Add timestamp to log file on Windows.
set logfile=%computername%.log.txt
set maxlines=1024
set /a taillines=%maxlines%-1
cd %~dp0
powershell -command "Get-Content %logfile% -Tail %taillines%" 1> tmp.txt 2> nul
type tmp.txt > %logfile%
echo %date% %time% >> %logfile%
del tmp.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment