How to Change File Date or Timestamp in Windows

Windows maintains three different date/timestamps for every file and folder. They are “Date Created”, “Date Modified”, and “Date Accessed”. In some situations, you may have to change the modified, created, or last accessed timestamp of a file or folder.

For instance, I had to change the timestamp of some files to test the Robocopy sync method when writing an article on folder compare and synchronization. Other users may need to change the date or time of a file for backup or archiving purpose.

Let’s see some methods to change the created date, modified date, or last accessed date of files in this article.

Change File Creation, Last Accessed or Modified Date

Using PowerShell

To change the file date using PowerShell, here are the commands you need to run:

Change the creation date/timestamp of a file named log1.txt:

(Get-Item "D:\Test\log1.txt").CreationTime=("3 August 2019 17:00:00")

Change the last write date/timestamp of a file named log1.txt:

(Get-Item "D:\Test\log1.txt").LastWriteTime=("3 August 2019 17:10:00")

Change the last accessed date/timestamp of a file named log1.txt:

(Get-Item "D:\Test\log1.txt").LastAccessTime=("3 August 2019 17:10:00")

Change the date/timestamp of all files in a folder named Test:

To change the timestamp of all files in a folder, use the following syntax:

Get-ChildItem -force d:\test\ * | ForEach-Object{$_.CreationTime = ("3 August 2019 17:00:00")}
Get-ChildItem -force d:\test\ * | ForEach-Object{$_.LastWriteTime = ("3 August 2019 17:10:00")}
Get-ChildItem -force d:\test\ * | ForEach-Object{$_.LastAccessTime = ("3 August 2019 17:10:00")}

Note that the above command changes the timestamp for every file and subfolder in a folder. To apply the change only for files (i.e., exclude sub-folders), use this syntax:

Get-ChildItem -force d:\test\ * | Where-Object {! $_.PSIsContainer} | ForEach-Object{$_.CreationTime = ("3 August 2019 17:00:00")}
Get-ChildItem -force d:\test\ * | Where-Object {! $_.PSIsContainer} | ForEach-Object{$_.LastWriteTime = ("3 August 2019 17:10:00")}
Get-ChildItem -force d:\test\ * | Where-Object {! $_.PSIsContainer} | ForEach-Object{$_.LastAccessTime = ("3 August 2019 17:10:00")}

Change the last write date/timestamp of a “Folder”

(Get-Item "D:\Test\").LastWriteTime=("3 August 2019 17:00:00")

View Created, Modified, and Last accessed date of all files in a folder

To view the date modified, date created, and date last written data for all files in a folder, use the following command-line syntax:

Get-ChildItem -force "D:\Test\"  | Select-Object Name, CreationTime, LastWriteTime, LastAccessTime

(or)

foreach ($objFile in Get-ChildItem "D:\Test\*.*") { '"' + $objFile.Name + '" | ' + $objFile.CreationTime + ' | ' + $objFile.LastWriteTime + ' | ' + $objFile.LastAccessTime}

You’ll see an output like this:

"log1.txt" | 08/03/2019 17:00:00 | 08/03/2019 17:10:00 | 08/03/2019 17:10:00
"log2.txt" | 08/03/2019 17:00:00 | 08/03/2019 17:10:00 | 08/03/2019 17:10:00
"log3.txt" | 08/03/2019 17:00:00 | 08/03/2019 17:10:00 | 08/03/2019 17:10:00
"log4.txt" | 08/03/2019 17:00:00 | 08/03/2019 17:10:00 | 08/03/2019 17:10:00

change last modified file date or timestamp using powershell


Using NirCmd from Nirsoft

Using NirCmd, a multi-purpose command-line tool from Nirsoft.net, you can change the file date and timestamp.

Here is the command-line syntax to change the file timestamp using NirCmd:

nircmd.exe setfiletime [filename or wildcard] [Created Date] {Modified Date} {Accessed Date}
  • The first parameter can be a single filename or wildcard string.
  • The dates parameters must be specified in the following format: “dd-mm-yyyy hh:mm:ss” if a date parameter is not specified or you specify an empty string (“”), the date won’t be changed.
  • If you specify "now" as the date parameter, the current date and time will be used.

Examples

nircmd.exe setfiletime "d:\test\log1.txt" "03/08/2019 17:00:00" "" "03/08/2019 17:10:00"
nircmd.exe setfiletime "d:\test\log2.txt" now now now
nircmd.exe setfiletime "d:\test\log3.txt" now "" now
nircmd.exe setfiletime "d:\test\log4.txt" "03/08/2019 17:00:00" "03/08/2019 17:10:00" now

To change the timestamp of all text files in a folder, here’s the command-line syntax:

nircmd.exe setfiletime "d:\test\*.txt" "03/08/2019 17:00:00" "03/08/2019 17:10:00" "03/08/2019 17:10:00"

Using BulkFileChanger from Nirsoft

BulkFileChanger is another useful tool from Nirsoft.net can modify the created, modified, or accessed time of one or multiple files. It can also change the file attributes (Read-Only, Hidden, System) en masse.

Start BulkFileChanger and add the files into it. When adding files to the list, you can optionally choose to add files in sub-folders and also set the recursion level accordingly.

change last modified file date or timestamp bulkfilechanger



Select all files, and click Change Time/Attributes from the Action menu.

You may want to uncheck the Time is specified in GMT first, as most of us prefer inputting the local time rather than the GMT.

Input the Created, Modified, or Accessed date/time. To fill up the current time in all the fields, click on the Fill Current Time button below.

change last modified file date or timestamp bulkfilechanger

For images taken from a camera, the EXIF or the metadata field contains the Date taken field, which is separate from NTFS’s date modified/created data. You can view the EXIF data from the JPG file’s properties, or using the ExifDataView utility from Nirsoft.net.

change last modified file date or timestamp bulkfilechanger

That said, BulkFileChanger also allows you to change the Date Taken timestamp (EXIF metadata). To change the date metadata, click on the No Change button, and select the appropriate option.

change last modified file date or timestamp bulkfilechanger

The EXIF – Generated Time corresponds to the Date Taken metadata, and this field is displayed under the Date column of File Explorer. Also, many programs use this value as the official date/time of the picture.

Note that you can change the EXIF date of a camera image only if the date/time values already exist inside the .jpg files. BulkFileChanger cannot add new fields into the EXIF data.

And, optionally, you can also copy the timestamp from Modified, Created, Accessed, EXIT – Generated Time, EXIT – Stored Time, or the EXIT – Modified Time and apply the same to other date fields automatically.

Command-line support

BulkFileChanger also supports command-line operations so that you don’t have to open the GUI every time. Check out BulkFileChanger homepage for command-line help/the list of arguments supported.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support, my reader. It won't take more than 10 seconds of your time. The share buttons are right below. :)

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.

Leave a Comment