Цитата V!RTuE:
Надо с точностью до секунд и в формате DD-MM-YYYY_HH-MM-SS (добавить знак _ после года и заменить : на - ) »
|
Например, можно использовать свойство «LastModified» класса «CIM_DataFile» посредством «wmic.exe»:
Код:

@echo off
setlocal enableextensions enabledelayedexpansion
set sSourceFile=E:\Песочница\0397\Sample.txt
if exist "%sSourceFile%" (
for /f "usebackq skip=1 delims=" %%i in (
`wmic.exe DataFile where "Name='%sSourceFile:\=\\%'" get LastModified`
) do for /f %%j in ("%%~i") do (
set sVar=%%~j
set sLastModified=!sVar:~6,2!-!sVar:~4,2!-!sVar:~0,4!_!sVar:~8,2!-!sVar:~10,2!-!sVar:~12,2!
echo !sLastModified!
)
) else (
echo Can't find source file [%sSourceFile%].
exit /b 1
)
endlocal
exit /b 0