@echo off & setlocal enableextensions
call :GetFileModifiedDateTimeSingle "%~1" datetimestamp_
echo.
echo %datetimestamp_% %~1
echo.
::
call :GetFileModifiedDateTimeParsed "%~1" wd_ HH_ MN_ ss_ dd_ MM_ yyyy_
echo wd_=%wd_%
echo HH_=%HH_%
echo MN_=%MN_%
echo ss_=%ss_%
echo dd_=%dd_%
echo MM_=%MM_%
echo yyyy_=%yyyy_%
echo.
::
echo %wd_% %dd_%.%MM_%.%yyyy_% %HH_%:%MN_%:%ss_%
endlocal & goto :EOF
:: The indentation is essential to avoid incorrect syntax
:GetFileModifiedDateTimeSingle
setlocal enableextensions
set file_=%~1
for /f "usebackq delims=" %%a in (`powershell -command ^
"(Get-Item '%file_%').LastWriteTime.ToString('ddd yyyy-MM-dd HH:mm:ss')"`) do (
set result_=%%a)
endlocal & set "%2=%result_%" & goto :EOF
:GetFileModifiedDateTimeParsed
setlocal enableextensions
set file_=%~1
for /f "tokens=1-8 usebackq delims=-: " %%a in (`powershell -command ^
"(Get-Item '%file_%').LastWriteTime.ToString('ddd HH:mm:ss dd-MM-yyyy')"`) do (
set a_=%%a
set b_=%%b
set c_=%%c
set d_=%%d
set e_=%%e
set f_=%%f
set g_=%%g
)
endlocal & set "%2=%a_%" ^
& set "%3=%b_%" & set "%4=%c_%" & set "%5=%d_%" ^
& set "%6=%e_%" & set "%7=%f_%" & set "%8=%g_%" & goto :EOF
The output might be e.g.
C:\_D\TEST>cmdfaq "C:\DIGIPHOTOS\Torig2026071701.JPG"
Fri 2026-07-17 12:36:11 C:\DIGIPHOTOS\Torig2026071701.JPG
wd_=Fri
HH_=12
MN_=36
ss_=11
dd_=17
MM_=07
yyyy_=2026
Fri 17.07.2026 12:36:11