Created
August 3, 2018 07:57
-
-
Save LAK132/2d0d4214afd205c18431fe67b879cebb to your computer and use it in GitHub Desktop.
Get a file's last modified epoch in batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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