How to Change File Dates (Created, Modified, Accessed) on Windows and Mac

13 min read

Online Tech Tips is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

You copy a folder of old files or photos from an external hard drive. Suddenly every single one says it was created today, and your neatly sorted folder becomes a jumbled mess. It’s one of the most quietly maddening things a computer can do. The good news is that you can change file dates on Windows and Mac with tools that are already installed. You don’t need registry hacks, admin tricks, or sketchy downloads.

Here’s the short answer. On Windows 11, PowerShell can rewrite a file’s Created, Modified, and Accessed dates with a one-line command. On a Mac, the Terminal touch command changes the Modified and Accessed dates. Changing the Created date takes Apple’s free SetFile tool. If a photo is sorting in the wrong spot, though, you probably need to fix its Date Taken inside your Photos app instead. That date is a separate thing entirely, and we’ll cover it too.

What Are File Dates, Anyway?

Every file carries a little history about itself. Your computer stores that history as timestamps, which are just the date-and-time labels attached to a file. Here’s what each one means in plain English:

  • Date Created: Usually when the file first appeared on this drive. That’s why copying a file often resets it to today, though whether the original is kept depends on the copy tool, the drives’ file systems, and how the file is transferred.
  • Date Modified: When the file’s contents were last changed and saved.
  • Date Accessed: When the file was last opened or read. On Windows this one isn’t reliable, because Windows can defer or skip updating it (itechguides). Don’t treat it as a true “last opened” record.
  • Date Taken (EXIF): A date stored inside a photo by your camera or phone. EXIF is just the name for the bundle of info a camera tucks into each picture. Many photo apps sort by this date rather than the file dates above, though exact behavior can vary by app, library, and import history.

Think of it like a letter. The file dates are the postmarks on the envelope. Date Taken is the date written on the letter itself. Changing one doesn’t change the other.

This guide is about tidying up your own files so they sort correctly. Don’t use timestamp editing to alter records, evidence, or deadlines. That’s not what these tools are for, and it can get you into real trouble.

Before You Begin

  • A Windows 11 PC (PowerShell is built in) or a Mac on a current macOS release (Terminal is built in)
  • A copy of the file you want to fix. These commands have no undo button.
  • The file saved somewhere local, not inside a OneDrive, iCloud Drive, or Google Drive folder (more on why below)
  • Mac only: about 10 minutes and an internet connection to install Apple’s free Xcode Command Line Tools, if you need to change the Created date
RequirementDetails
DeviceWindows 11 PC or Mac
OS versionWindows 11; current macOS release
CostFree (built-in tools)
Extra downloadMac only: Xcode Command Line Tools, for SetFile

Tip: If you’re rescuing files from an old backup, copy them to your desktop first. Fix the dates there, then move them back to your external SSD or backup drive. Working on copies is the single best habit for this whole job.

Step-by-Step Guide

On Windows

Step 1: Check the File’s Current Dates

  • Open File Explorer and find your file.
  • Right-click the file and choose Properties.
  • Click the Details tab and scroll down.

You’ll see Date created, Date modified, and Date accessed. Jot these down so you can put them back if needed.

File Explorer Properties dialog on the Details tab with Date created, Date modified, and Date accessed fields highlighted

Step 2: Copy the File’s Full Path

Right-click the file and choose Copy as path. This puts the file’s full location (something like C:\Users\You\Pictures\beach.jpg) on your clipboard, wrapped in quotes. You’ll paste it into the commands below.

Step 3: Open PowerShell

Click Start, type PowerShell, and press Enter. You can also press Win + X and choose Terminal. A window with a blinking cursor appears.

Running as administrator usually isn’t required for files in your own user folders, but locked, system, or read-only locations may still need elevated permissions.

Step 4: Change One File’s Dates

Type or paste this command, swapping in your own path and date:

(Get-Item -LiteralPath 'C:\Users\You\Pictures\beach.jpg').CreationTime = [datetime]'2019-07-14 09:30:00'

Here’s what each piece does:

  • Get-Item grabs the file so PowerShell can work with it.
  • -LiteralPath '...' points to the file. It also tells PowerShell to treat spaces and odd characters in the name as plain text. Use single quotes around the path.
  • .CreationTime picks the date to change. Swap it for .LastWriteTime to change Date modified, or .LastAccessTime to change Date accessed.
  • = [datetime]'2019-07-14 09:30:00' sets the new date. The format is year-month-day, then hours:minutes:seconds in 24-hour time.

Press Enter. If it worked, PowerShell says nothing at all and simply shows a new prompt. In PowerShell, silence means success. To change all three dates, run the command three times, once with each property name.

Step 5: Confirm the Change

Get-Item -LiteralPath 'C:\Users\You\Pictures\beach.jpg' | Select-Object Name, CreationTime, LastWriteTime, LastAccessTime

This lists the file name and its three dates (powershellfaqs). You should see your new date. You can also reopen Properties > Details to double-check.

PowerShell window showing a CreationTime command followed by the Select-Object verification command, with the updated date values highlighted in the output

Step 6: Change a Whole Folder at Once (Optional)

Got 200 vacation photos that all need the same fix? Try this instead of editing them one by one (squintz.org):

Get-ChildItem -LiteralPath 'C:\Users\You\Desktop\Trip Copy' -File | ForEach-Object { $_.LastWriteTime = [datetime]'2019-07-14 09:30:00' }
  • Get-ChildItem ... -File lists every file in that folder and skips subfolders.
  • | (the “pipe”) hands that list to the next command.
  • ForEach-Object { ... } runs the code in the curly braces once for each file.
  • $_ means “the file we’re on right now.”

Every file in the folder gets the same Date modified. Run Step 5’s check on one of them to confirm.

On macOS

Step 1: Check the File’s Current Dates

Select the file in Finder and press Command + I (or right-click and choose Get Info). Under General, you’ll see Created and Modified. Write them down. Get Info doesn’t show the Accessed date; the stat command in Step 4 shows all three, including Accessed.

Finder Get Info window for a sample file with the Created and Modified dates highlighted in the General section

Step 2: Open Terminal

Press Command + Space, type Terminal, and press Return.

Tip: You don’t need to type long file paths. Type the command, add a space, then drag the file from Finder into the Terminal window. macOS fills in the full path for you.

Step 3: Change the Modified and Accessed Dates with touch

touch -t 201907140930 "/Users/yourname/Desktop/beach.jpg"
  • touch is the built-in command that updates file timestamps.
  • -t 201907140930 is the new date written as YYYYMMDDhhmm. This example is July 14, 2019, at 9:30 a.m. You can add seconds at the end with a period, like 201907140930.15.
  • The quoted path is your file. Keep the quotes if the name has spaces.

On macOS, touch -t sets both the Accessed and Modified dates unless you limit it (see the macOS touch reference, or run man touch). Add -m to change only Modified, or -a to change only Accessed.

Here’s the catch that most guides skip. touch can’t push the Created date forward or set it to anything you choose. It can, however, drag Created backward. If your new date is earlier than the file’s current Created date, macOS moves Created back to match (publicspace.net). Sometimes that’s handy. Sometimes it’s a surprise.

Step 4: Confirm with stat

stat -f "created %SB modified %Sm accessed %Sa" "/Users/yourname/Desktop/beach.jpg"

Terminal prints one line with all three dates, so you can check your work without leaving the window.

Terminal window showing a touch -t command on a sample file followed by the stat command, with the stat output line showing the created, modified, and accessed dates highlighted

Step 5: Install the Xcode Command Line Tools (Only If Needed)

To set the Created date to a specific value, you need SetFile. Type SetFile and press Return. If you see command not found, install Apple’s free tools:

xcode-select --install

A pop-up window appears. Click Install, accept the license, and wait for it to finish. This is a free download from Apple, not a third-party app (picklog).

Step 6: Change the Created Date with SetFile

SetFile -d "07/14/2019 09:30:00" "/Users/yourname/Desktop/beach.jpg"
  • -d means “set the creation date.”
  • “07/14/2019 09:30:00” uses the US format MM/DD/YYYY HH:MM:SS. Always include the time. Leaving it off can produce wrong results.
  • Swap -d for -m to set the Modified date the same way.

Run the stat command from Step 4 again, or reopen Get Info, to confirm the new Created date.

Apple has deprecated SetFile (run man SetFile to see Apple’s deprecation note; SS64 has a command reference), so a future Xcode or Command Line Tools release may drop it. If SetFile is missing after you install the tools, it may have been removed in your version, and the touch trick that pulls Created backward (Step 3) is the remaining built-in option.

Prefer Clicking Over Typing?

On Mac, publicspace.net (the developer behind the Mac file-date explainers cited here) makes a point-and-click app called A Better Finder Attributes. It shows date fields in a regular window instead of Terminal. Check its current version, price, and features on the developer’s own site before you download, and only get it from there.

For Windows, the built-in point-and-click option is limited to photos: File Explorer’s Properties > Details tab can edit Date taken for many JPEGs (see below), but it can’t edit Created or Modified. We haven’t vetted a third-party Windows date editor we’re comfortable recommending, so PowerShell is the safest way to change those dates.

Fixing a Photo’s “Date Taken”

If your Photos app still sorts a picture in the wrong place after you change its file dates, this is why. Photo apps read the Date Taken stored inside the image, not the file’s Created or Modified date. Fix that date in the app itself.

On Windows

Right-click the photo and choose Properties > Details. Look under Origin for Date taken. For many JPEG photos, you can click that value to edit it, then click Apply. If the field won’t let you edit it, that file type doesn’t support editing there.

File Explorer Properties Details tab for a JPEG photo with the Date taken field under the Origin section highlighted

On macOS

Open the photo in the Photos app and select it. Then look for Adjust Date and Time, which is usually in the Image menu (its menu location has moved between macOS versions). Enter the correct date and click Adjust.

Keep in mind that Photos stores this edit in its own library database, not in the original image file. The adjustment stays there until you export a copy.

When you export, Photos can write the adjusted date into the exported JPEG or HEIC file’s metadata, but only if you choose export options that carry metadata along, such as exporting an edited (not “unmodified original”) version with metadata included. If you export the unmodified original, or export without those metadata options, the exported file’s EXIF date may still show the original, unedited value.

Photos app Adjust Date and Time dialog with the Adjusted date field and Adjust button highlighted

Configuration: Which Setting Changes What

Tool / SettingChangesDate Format
PowerShell CreationTimeDate created‘2019-07-14 09:30:00’
PowerShell LastWriteTimeDate modifiedsame
PowerShell LastAccessTimeDate accessedsame
Mac touch -tModified + Accessed (can pull Created backward)YYYYMMDDhhmm
Mac SetFile -dCreated onlyMM/DD/YYYY HH:MM:SS
Photos appsDate Taken shown in-app and stored in the library; carries into an exported file’s EXIF only if you pick export options that include the adjusted metadataApp’s date picker

Tips and Troubleshooting

Problem: PowerShell won’t change the date, or nothing seems to happen

  • The file may be marked read-only. Run (Get-Item -LiteralPath 'C:\path\file.jpg').IsReadOnly = $false.
  • Then run your date command again.

Problem: PowerShell shows an error or edits the wrong file

  • Use the full path, including the folder location, instead of only the file name.
  • Wrap the path in single quotes and keep -LiteralPath in the command.

Problem: The time I set doesn’t match File Explorer

  • PowerShell has UTC versions of each date, such as CreationTimeUtc. UTC is a worldwide standard time that ignores your time zone.
  • Add CreationTimeUtc to your Select-Object check to see which version matches what Explorer shows.

Problem: Terminal says “SetFile: command not found”

  • Run xcode-select --install and finish the installer.
  • Quit and reopen Terminal, then try again.

Problem: Changing the Modified date on my Mac also changed the Created date

  • That’s touch pulling Created backward. Next time, save the original first with stat -f "%SB" "your-file".
  • After using touch, put the original Created date back with SetFile -d.

Problem: My fixed date changed back after syncing or copying

  • Cloud sync services such as OneDrive, iCloud Drive, and Google Drive can sometimes re-stamp file dates during upload or download, though behavior varies by service, settings, and platform. Plain copying can reset the Created date too, regardless of cloud sync.
  • Fix dates on a local copy, confirm they look right, then move the file into the synced folder. Even then, some sync apps may still shift dates, so check again afterward.

Will this break anything? Changing timestamps on your own files doesn’t change their contents, but it can change how other software treats them, including sorting, search indexing, backups, sync, and duplicate finders.

That said, some backup, sync, or indexing tools that watch for “recently changed” files may react to the new timestamp by skipping, re-copying, or re-scanning it. This is for organizing your own files, not for rewriting history on official documents.

Keep a Before-and-After Note: Paste the output of the Select-Object or stat check into a text file before you change anything. It’s your homemade undo button.

Wrapping Up

Once you know which date your app actually reads, fixing out-of-order files gets a lot less mysterious. Use PowerShell on Windows, touch and SetFile on Mac, and your Photos app for Date Taken. Honestly, the command line sounds scarier than it is. Most of the real headaches come from cloud sync and copying quietly undoing your fix, so always work on a local copy first.

StepActionApplies To
1Check current dates in Properties or Get InfoWindows, Mac
2Set dates with CreationTime, LastWriteTime, LastAccessTimeWindows
3Set Modified and Accessed with touch -tMac
4Set Created with SetFile -d (Command Line Tools)Mac
5Fix Date Taken in Properties or the Photos appWindows, Mac
6Move fixed files into cloud folders lastWindows, Mac

Resources

Sources