How To Change A File/Folder Date Timestamp Using Command Line And Other Tools

In Windows 10 and 11, every file and folder contains certain attributes that help define their properties. In this post, we will discuss the following attributes: Date ModifiedDate Created, and Date Accessed. If you need to modify these attributes, there are a few methods you can use, including the command-line approach and some third-party tools.  

This information can be found in every file or folder, regardless of the type of file, which means that each document, photo, video, zipped file, and folder carries this information with them wherever they are transferred. Those who are interested in knowing this information about a particular item only need to examine its properties or metadata.  

The date modified, the date created, and the date accessed are referred to as timestamps. There is a record of the last time the respective changes were made. In addition, these are used by the system to save previous versions of a file/folder by reading, if it is designed to archive or save its last version.

Date Modified, Date Created, and Date Accessed

As in the example below, the 3 attributes can be seen in File Explorer. You may notice how each category displays both the date as well as the time of the event for each item.

Attributes displayed in File Explorer

Date Modified depicts the event when the last changes were made to the item. In the case of a text document, anything added or removed from it will automatically update the Date Modified timestamp to the current time. In the case of a folder, any changes made to the contents within the folder, such as new items added or removed, will change the Date Modified timestamp. However, if you were to modify a file within a folder, the Date Modified timestamp of the parent folder will not change.

Some may think that the Date Modified attribute is dependent upon the hard drive it is saved on, and not the metadata of the item. However, this theory is not true. You can verify this by creating a test document in one place, and then moving it to another storage device at another time. You will notice that the new copy of the item still retains its old Date Modified timestamp.

Similarly, Date Created is the date and time when an item was first created. This does not change when you make changes to an item, nor does copying it to another storage device. However, if you make a new copy of an existing file or a folder, the Date Created is automatically updated for the new copy to the current time.

Lastly, as the name suggests, the Date Accessed tells us of the last time an item was accessed. It does not necessarily have to be modified Read-only privileges will also change this timestamp to the current time.

How to Modify file and folder timestamps

Now that you understand what each timestamp indicates and how they are modified, let us move on to manually change them in case you ever need to.

All 3 timestamps can be changed to your requirements manually. To do so, there are tools present on the internet, and it can also be done through your Windows command line. Remember that modifications need to be a time of the past, and not of the future. Setting the timestamps to a future time will make the information disappear from the Explorer.

Change Date Modified, Date Created, and Date Accessed using Windows PowerShell

Windows PowerShell is a command-line tool that comes preinstalled in Windows 10 and 11. It is super-handy for superusers as it allows you not only to control your Operating System but also lets you automate tasks. Similarly, you can use the commands given below to modify the 3 timestamps to your preferences.

Change Date Modified

Launch Windows PowerShell with administrative privileges and then use the following command to change the Date Modified in the file/folder:

(Get-Item "PathToItem").LastWriteTime=("14 August 2016 13:14:00")

Remember to replace PathToItem in the command above with the complete path to the file/folder that you wish to change the attribute of (including the file type). Also, change the date and time to your preference. Here is an example:

(Get-Item "D:\TestDocument.txt").LastWriteTime=("14 August 2016 13:14:00")
date modified ps
PowerShell: Command to Manipulate Date Modified Attributes

Run the command above and make changes to the text file in the D drive named “TestDocument.txt.” This was then verified through File Explorer. Here are the results:

date modified ps results
Date Modified timestamp for TestDocument has been changed

Change Date Created

Likewise, you can also manipulate the Date Created attribute of a file/folder using the command below:

(Get-Item "PathToItem").CreationTime=("13 August 2015 13:18:00")

As in the last example, change the PathToItem as well as the date and time of your preference in the command above. Here is an example of us changing the Date Created attribute of a folder named “Newfolder” in the D drive:

date created ps
PowerShell: Command to manipulate Date Created attribute

As expected, the Date Created attribute has been changed.

date created ps results
The date Created timestamp for Newfolder has been changed

Change Date Accessed

To manipulate the Date Accessed attribute using PowerShell, use the command below:

(Get-Item "PathToItem").LastAccessTime=("3 August 2019 17:10:00")

Always change the PathToItem as well as the date and time according to your preferences.

We shall not dwell on an example and its results, as you have already seen in the manipulation of the Date Modified and Date Created timestamps.

However, in case you notice that the Date Accessed is not changing on your system, it is very likely that the feature has been turned off. You can easily activate it by launching Command Prompt with administrative privileges, and then pasting the command given below:

sutil behavior set disablelastaccess 0
Activate Date Accessed attribute

You should now be able to see an updated Date Accessed timestamp each time you open a file or a folder.

Change all 3 attributes of all items within a folder

You can also change all 3 timestamps of all the items within a folder. To do so, simply use the commands shown below, adjust them to your requirements, and voila! You are done changing the timestamps in a jiffy.

Get-ChildItem -force PathToItem * | ForEach-Object{$_.CreationTime = ("14 August 2016 13:14:00")}
Get-ChildItem -force PathToItem * | ForEach-Object{$_.LastWriteTime = ("14 August 2016 13:18:00")}
Get-ChildItem -force PathToItem * | ForEach-Object{$_.LastAccessTime = ("14 August 2016 13:22:00")}

Remember to replace PathToItem with the complete path of the folder as well as the date and time that you wish to configure.

ps all in one
PowerShell command to change all 3 attributes within a folder

As you can see in the image below, all contents within the folder named “Newfolder” have updated their attributes as commanded through PowerShell.

ps all in one results
All 3 attributes changed within a folder

There are other similar commands you can use in Windows PowerShell to change the attributes of any file or folder. Nonetheless, all have a similar effect to that which we have discussed in this post.

Change Date Modified, Date Created, and Date Accessed using Attribute Changer

Attribute Changer is a small GUI-based utility that you can install on your system to manipulate the attributes of any file or folder using the context menu. Follow the steps below to install the tool and then learn how to use it in a few easy steps.

Open the Attribute Changer page and then click on Get Attribute Changer. The setup will then start to download. Once completed, click on it to begin the installation. The installation wizard will then open. Agree to the terms and conditions and follow through with the wizard in a few quick steps. The installation part only takes a few minutes.

Once installed, the app will not open by itself, since it is programmed to be launched through the context menu when you right-click a file or a folder.

context menu
Attribute Changer in the context menu

To change a file or folder’s Date Modified, Date Created, or Date Accessed, simply right-click on it and then click Change Attributes on the context menu.

Note: You may need to click Show more options in the context menu if you are using Windows 11.

Clicking Change Attributes will open the Attribute Changer in a new window showing the details of the item that you have selected. In the File Properties tab, check the box next to “Modify date and time stamps.” The greyed-out portion below will now be active and can be modified. You can now adjust the Date Modified, Date Created and Date Accessed according to your own preferences using these options.

attribute changer
Attribute Changer

Once the required changes are made, click on Apply and then OK. You will now notice that the changes have been updated in File Explorer.

AC results
Changes made through Attribute Changer

We would like to point out that changing the timestamps of an entire folder will not affect its contents. Therefore, you will be required to change them for each item individually.

Change Date Modified, Date Created, and Date Accessed using NirCmd

NirCmd is a third-party command-line tool by Nirsoft that allows you to perform certain advanced tasks through the Command Prompt. It can also be used to change the Date Modified, Date Created, and the Date Accessed attributes of any file on the computer.

Use the following steps to download and use NirCmd to modify these attributes for any given file:\

  1. First, download the NirCmd utility for their website.

  2. Extract the package by right-clicking it, and then clicking “Extract all.” Click Extract again on the extraction wizard.

  3. Now, press the Windows Key + R to open the Run Command box.

  4. Type in “cmd” and press CTRL + Shift + Enter to launch an elevated Command Prompt.

  5. Use the “CD” command, in the following syntax, followed by the patch to the extracted folder, to change the directory to it.

    Cd /d [PathToExtractedFolder]
    Navigate to the extracted NirCmd folder
    Navigate to the extracted NirCmd folder
  6. Now use the following syntax to change the timestamp of your respective file by providing its complete path. Also, specify the date parameters in the format: dd-mm-yyyy hh:mm:ss

    Note: You can leave the string empty by inserting only parenthesis if you want to keep a date unchanged.

    nircmd.exe setfiletime [FilePath&Name] [Created Date] [Modified Date] [Accessed Date]
    Change file timestamp using NirCmd
    Change file timestamp using NirCmd

After performing the steps above, you will notice that the new timestamp has been applied to the file successfully.

New timestamp assigned successfully
New timestamp assigned successfully

To change the timestamp of all the files with a folder, use an asterisk (*) instead of the file name in the command, like in this example:

nircmd.exe setfiletime "D:\Newfolder\*.txt" "11-11-2011" "11-11-2011" "11-11-2011"

Reasons to change date/timestamp

You might want to change the timestamp, the date accessed, the date created, or the date modified for a file or folder for several reasons. Here are a few reasons why one might want to:

  • Changing the date parameter helps sort files accordingly. For example, you may want to sort all the files according to their “Date Modified” attribute, but one file is not where it should be. Therefore, you may need to change its date to bring it to its correct place.
  • You may want to perform a version control if you are a developer. For example, if a file version is out of its correct modified date, you can correct it before rolling it out.
  • Maintaining accurate records of file creation date, modified date, and accessed date is sometimes a legal requirement for some organizations. It is possible to guarantee adherence to these rules by changing these attributes.
  • You may want to change the timestamp to protect your privacy and security, especially if you are planning on sharing the items with someone else and do not want them to find out its exact date of creation, or the last time it was accessed.

Closing words

Timestamps provide insight into the digital content they are associated with. Documents and folders contain these digital time signatures embedded in their metadata. Using the guide provided in this post, these can be modified for any given reason in a few minutes.

Additionally, there are other tools available online for manipulating these stamps. However, Attribute Changer has proven to be the most convenient to use.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Leave the first comment

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information