Changing File Creation and Modification Dates in Linux, macOS, and Windows (Updated 2025)
Introduction
There are times when you need to modify file timestamps—whether for organization, file restoration, or digital forensics. While file creation dates are difficult to change natively in some operating systems, modification and access dates can be easily adjusted using built-in tools. This guide covers the best methods for modifying file timestamps on Linux, macOS, and Windows using command-line tools and third-party utilities.
Understanding File Timestamps
Operating systems track various timestamps for files, which determine when a file was created, modified, or accessed. Here’s what each timestamp represents:
- Creation Time (
CreationTime
in PowerShell)- This is the original date and time when the file was first created on the system.
- In most cases, this timestamp remains unchanged unless explicitly modified.
- Some file systems, like ext4 on Linux, do not support changing the creation time natively.
- Last Write Time (Modification Time) (
LastWriteTime
in PowerShell)- This timestamp is updated when the file’s contents are modified.
- Editing the file and saving changes will update the Last Write Time automatically.
- Last Access Time (
LastAccessTime
in PowerShell)- This timestamp updates when the file is opened or read, but not necessarily modified.
- Depending on system settings, Windows and Linux may disable automatic updates to this timestamp to reduce disk I/O overhead.
These timestamps are useful for file organization, forensic analysis, and compliance with data retention policies. In Windows, PowerShell provides direct methods to manipulate these values, while on Linux/macOS, different tools like touch
or debugfs
may be required.
Changing File Dates in Windows
Using PowerShell
Windows does not have a native way to change creation dates, but you can use PowerShell:
Example: Change modification and access dates
(Get-Item myfile.txt).LastWriteTime = Get-Date "2024-03-07 15:30:00"
(Get-Item myfile.txt).LastAccessTime = Get-Date "2024-03-07 15:30:00"
Example: Change the creation date
(Get-Item myfile.txt).CreationTime = Get-Date "2024-03-07 15:30:00"
Using Third-Party Tools (For GUI Users)
For those preferring a GUI, tools like BulkFileChanger (by NirSoft) allow easy modification of file timestamps in Windows.
Changing File Dates in Linux
Using the touch
Command (Modification & Access Time)
The touch
command is the easiest way to change the modification and access times of a file.
Example: Change both modification and access times
touch -t 202403071530 myfile.txt
This sets the timestamp to March 7, 2024, 15:30 (3:30 PM).
Example: Change only the modification time
touch -m -t 202403071530 myfile.txt
Example: Change only the access time
touch -a -t 202403071530 myfile.txt
Changing the Creation Date (Linux Workaround)
Linux file systems (ext4, XFS, etc.) do not allow direct modification of the creation date. However, you can:
- Copy the file to create a new one with a new creation date:
cp --preserve=timestamps oldfile.txt newfile.txt
- Use debugfs (For ext4 file systems only):
sudo debugfs /dev/sdX stat /path/to/file set_inode_field /path/to/file crtime 202403071530
Changing File Dates in macOS
macOS supports the touch
command like Linux, but you can also modify metadata using SetFile
.
Using touch
touch -t 202403071530 myfile.txt
Using SetFile
(for Creation Dates)
macOS has a built-in utility for modifying creation dates:
SetFile -d "03/07/2024 15:30:00" myfile.txt
(Note: SetFile
is part of Apple’s Xcode Command Line Tools.)
Conclusion
Modifying file timestamps is straightforward with the right tools. While changing creation dates is restricted in some operating systems, workarounds exist for Linux, macOS, and Windows. Whether you’re a system administrator, developer, or forensic investigator, these methods provide precise control over file metadata.
For further automation, consider writing scripts to batch-edit timestamps across multiple files!