Tell me how you can find out the date the file was created in BAT. We have a variable for %%~ti, but it only indicates the file's modification date. And how do you know it is the date the file was created?
Asked
Active
Viewed 3,563 times
0
-
Doing date time handling in .bat files is quite hard. Isn't it possible for you to switch to powershell? There it is much easier, as you can see [here](http://stackoverflow.com/a/10433623/1838048). – Oliver Sep 22 '15 at 06:29
-
There is an option: FOR /f %%i IN ('DIR "%~1" /t:c ^| FINDSTR /E "%%~nf%%~xf"') DO ECHO %%i >> "%~2" It is necessary to remove the recurrence – Singularity303 Sep 22 '15 at 06:45
-
you surely mean `FINDSTR /E "%~1"`? – Stephan Sep 22 '15 at 06:50
2 Answers
1
@echo off
for /f "skip=5 tokens=1,2 delims= " %%a in ('dir /a-d /tc "%~1"') do (
echo Date: %%a, Time: %%b, File: %~1
exit /b 0
)

Paul
- 2,620
- 2
- 17
- 27
0
At least these three options exist, which are all scriptable.
There can be limitations depending on the OS version, and the language, and characters being used.
- Powershell
- WMIC
- VBS script using WSH

foxidrive
- 40,353
- 10
- 53
- 68