Categories: Files

Get file creation date and time

We can find creation date of a file from command line using dir command.  The syntax for this is given below.

dir /T:C filename

If we need to get file creation date and time for all the files and subdirectories in the current directory, the command is:

dir /T:C

We can also restrict the output to specific file types using wildcards.

dir /T:C  *.pdf

The above command would print file creation dates only for pdf files.

Command to print file creation date and time only for files(skip directories)

dir /A:-D /T:C

Find the latest created file in a directory:
The below command would print the files in the order of creation date & time. In this list the file that is created very recently would be displayed in the last position.

dir /A:-D /T:C /O:D

Example:

C:\>dir /A:-D /T:C /O:D
02/06/2012  07:38 PM                 4 4.txt
02/06/2012  07:39 PM                 0 5.txt
02/06/2012  10:45 PM                13 10.txt
02/06/2012  10:47 PM                13 newfile.t
02/11/2012  08:24 PM                83 2.bat
02/11/2012  08:26 PM             5,219 data.txt
02/11/2012  08:27 PM             5,219 data2.txt
02/12/2012  11:28 PM                98 3.bat
02/13/2012  10:47 AM               131 echo.bat
Srini

View Comments

  • The dir command seems to always output the creation date of files. The /T switch only tells on which date field to sort the output on. This has only effect if you use it with the /o:d option:
    dir /t:a /o:d
    will sort the files according to ther lastaccessed date, but will output the creation date for all.

  • I used these commands, but the times are the same for many files. When I look at the Date and/or Media Created columns in a Windows folder, I can see the correct creation date and times for the files.

Share
Published by
Srini

Recent Posts

Add new user account from command line (CMD)

Adding users from command line is much easier than going through the UI. It saves…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows command prompt(CMD)? This post explains how…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago

How to check if Windows 32 or 64 bit?

There are multiple ways to check whether a Windows computer is running 32-bit OS or…

7 years ago