Skip to content

Instantly share code, notes, and snippets.

@LAK132
Created August 3, 2018 07:57
Show Gist options
  • Save LAK132/2d0d4214afd205c18431fe67b879cebb to your computer and use it in GitHub Desktop.
Save LAK132/2d0d4214afd205c18431fe67b879cebb to your computer and use it in GitHub Desktop.
Get a file's last modified epoch in batch
@if (@a==@b) @end /*
@echo off
SetLocal EnableDelayedExpansion
set EPOCH=0
FOR /F "delims=" %%D in ('cscript /nologo /e:jscript "%~f0" "%1"') do (
set EPOCH=%%D
)
echo Last modified (epoch-seconds): !EPOCH!
goto :eof
*/
var fs = new ActiveXObject("Scripting.FileSystemObject");
var filename = WSH.Arguments(0)
var millis = -1
if (fs.FileExists(filename))
{
var file = fs.GetFile(filename);
millis = Date.parse(file.DateLastModified) / 1000;
}
WSH.Echo(millis);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment