简体   繁体   中英

How do I find the file creation date to the bat?

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?

@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
)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM