Using Windows PowerShell, you can change the creation date and time, the date and time last modified, and the date and time of the last accessed all files in Windows.
On Windows and other operating systems, each file will have certain attributes that help determine its properties.
In Windows, each file will have a timestamp that includes
- Date and time of creation.
- The date and time were last modified.
- The date and time last accessed.
You can find this information in each file or folder, regardless of the type of file, whether the file is a document, photo, video, zip file, and folder. If you copy or move the file elsewhere, this information will also follow the file.
To check the timestamp you can do it with Windows File Explorer and then right-click the file and select “Properties“.
If you need to modify this timestamp attribute, there are several methods you can use, including a command-line approach by using PowerShell and some third-party tools.
Change the creation date and time on a File in Windows
To change the date and time of the creation of the File, you can do it by typing a command in the following format in Windows PowerShell.
(Get-Item "FilePath"). CreationTime=("mm/dd/yyyy hh:mm:ss")
For example, to change the creation date of the file “D:bardimintes01.txt”, it would be something like this.
(Get-Item "D:\bardimin\tes01.txt"). CreationTime=("08/29/2022 9:45:00")
Change the Date and Time Last Modified in Files in Windows
As for changing the last information of the edited file, you can use the command:
(Get-Item "FilePath"). LastWriteTime=("mm/dd/yyyy hh:mm:ss")
Change the Date and Time Last Accessed in Files in Windows
To change the date and time a file was last accessed by a user, use the following command.
(Get-Item "FilePath"). LastAccessTime=("mm/dd/yyyy hh:mm:ss")
Other Interesting Articles
Change the date and time of all Files in a Folder in Windows
You also change at once all the files in one folder and all the timestamps by using the following command in PowerShell.
$modifyfiles = Get-ChildItem -force FolderPath | Where-Object {! $_.PSIsContainer} foreach($object in $modifyfiles) { $object.CreationTime=("mm/dd/yyyy hh:mm:ss") $object.LastAccessTime=("mm/dd/yyyy hh:mm:ss") $object.LastWritetime=("mm/dd/yyyy hh:mm:ss") }
FolderPath: The path of the target folder.
As an example of changing all the timestamps of files in the “D:\bardimin” folder, the writing will be like this.
$modifyfiles = Get-ChildItem -force D:\bardimin\* | Where-Object {! $_.PSIsContainer} foreach($object in $modifyfiles) { $object.CreationTime=("08/29/2002 9:45:00") $object.LastAccessTime=("08/29/2002 9:45:00") $object.LastWritetime=("08/29/2002 9:45:00") }