Is there a way to batch change the “Date Created” on 1,000’s of .PDF files at once?

I need to find a way to edit the “Date Created” section of 1,000’s of .pdf files to be 3 minutes apart from one another.  It doesn’t matter what order they are in.  Just so long as all of the files appear to have been created 3 minutes apart from one another.  




Doing so will enable me to be paid $10 more an hour which may not sound like much, but I’ll take anything if it helps me move out of my parents abode faster, lol.  




Eternally grateful to anybody who can crack it!

Mac mini, macOS 12.6

Posted on Jan 7, 2025 7:35 PM

Reply

Similar questions

4 replies

Jan 10, 2025 4:16 PM in response to MLVARBLE

This is actually a little tricker than it first sounds, for two reasons.


One is that you want to increment the timestamp on each file (so you need to keep some kind of counter), the second is there are very few ways of changing the creation date of a file.


First, to change creation dates, you need to download and install Xcode from Apple's: https://apps.apple.com/us/app/xcode/id497799835?mt=12


If you're not a developer, you can ignore 99% of what gets installed, but you will need the command line tool setfile (you might be able to get away with just downloading and installing the Xcode command line tools from: Command Line Tools for Xcode 16.2.dmg but I haven't verified this).


Once you have setfile installed, the next part is to iterate through your files making the changes.


This AppleScript I whipped up prompts the user for a folder and then changes all the files in that folder to have consecutive creation and modification dates, on a 3-minute incremement.


Copy and paste the script into a new Script Editor document and click Run. The comments tell you what each step does:


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

-- starting date for the first file
set thedate to date "1/1/2025 at 00:00:00"
-- how much time to add for each incremental file
set theOffset to 3 * minutes

tell application "Finder"
	-- ask the user for the folder to process, and get a list of files
	set theFiles to every file of (choose folder) as alias list
	
	-- loop through the files
	repeat with each_file in theFiles
		-- format the date in a specific format
		set date_string to my formatDate(thedate)
		-- use setfile to make the change
		do shell script "setfile -d '" & date_string & "' -m '" & date_string & "' " & (get POSIX path of file each_file)
		-- increment the date for the next file
		set thedate to thedate + theOffset
	end repeat
end tell


on formatDate(the_date)
	-- setfile requires the date in a specific format.
    -- This handler converts from AppleScript's date to something setfile can use.
    set {y, m, d, t} to {year, month, day, time string} of the_date
	set {myTID, my text item delimiters} to {my text item delimiters, ":"}
	set {hr, min, sec} to text items 1 through 3 of t
	set my text item delimiters to myTID
	set returnString to (m as number) & "/" & d & "/" & y & space & hr & ":" & min & ":" & sec as text
	return returnString
end formatDate



Change the starting date at the top of the script. This will be the date used for the first file.

The increment is set in the next line (3 * minutes). You can set this to any number of seconds (where AppleScript knows that a minute is 60 seconds, so 3 * 60 =180


The script then prompts for a folder and will blindly change all the files in that folder to have new creation and modification dates. There is no error checking (e.g. for valid dates, file types, etc.), and there is no undo, so make sure you select the right folder.

Jan 7, 2025 8:25 PM in response to MLVARBLE

You can do so if you have some knowledge of shell scripts and working in the Terminal. All of the information needed to create a shell script to do this is available here: https://apple.stackexchange.com/questions/398425/change-file-creation-date-to-content-created-date-using-terminal


Just make sure you are confident in your skills and understand the concept of the working directory when testing your creation. Shell scripts are an extremely powerful tool that can really make a mess of your Mac if you were to accidentally target unintended files.

Jan 10, 2025 4:15 PM in response to Camelot

Oh, another consideration - you might want to add some randomization to the date stamp, since exactly 3 minutes apart would look odd to anyone who's checking.


My suggestion would be to to change the line:


		set thedate to thedate + theOffset


to


		set thedate to thedate + theOffset + (random number from -30 to 60)


this will result in timestamp variances between 2:30 and 4 minutes, which may be a little more believable :) Just expand the lower and upper bands for whatever level of variance you want.


Secondly, note that the PDF file may contain internal metadata relating to dates in addition to the file system creation and modification dates. This script won't change them, and a skilled user may look at this 'internal' date and notice a discrepancy. This may or may not be an issue for you.



Jan 9, 2025 3:03 AM in response to FishingAddict

Apologies for coming back with yet another query, but I am very new to this. So if you could PLEASE take some time to create a little layman step by step for me that I can refer to batch change the “date created” and “date modified" on 1,000’s of .pdf files. They can all be created at the same time, totally fine. I just don’t really know where to begin is all.

Many tnx n'w/ sincerity,

- Michael

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Is there a way to batch change the “Date Created” on 1,000’s of .PDF files at once?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.