M
M
Michael2015-09-22 09:18:28
cmd/bat
Michael, 2015-09-22 09:18:28

How to find the creation date of a file in bat?

Tell me how you can find out the creation date of a file in BAT.
for has a %%~ti variable, but it only points to the modification date of the file. How can I find out the creation date of a file?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2015-09-22
@Sing303

Earned as follows

FOR /f "usebackq tokens=1,2,3,* delims= " %%a IN (`dir /-c /tc "%%f"`) DO IF "%%d" == "%%~nf%%~xf" ECHO %%a >> "%~2"

E
Eugene, 2015-09-22
@yellowmew

you can, for example, extract from here:

dir 123.txt /T:C покажет дату создания.
dir 123.txt /T:W покажет дату изменения.

although it's much easier to do in PowerShell:
(Get-Item .\123.txt).CreationTime
(Get-Item .\123.txt).LastWriteTime

and no need to suffer with processing the result of dir

M
Max, 2015-09-22
@MaxDukov

Mikhail : FOR /F "tokens=1,2 skip=5" %%i IN ('DIR %1 /tc ') DO (echo %%i %%j && exit 0
) output have the date and time. If you don't need time, just remove %%j in echo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question