Change creation date based on file name

Assuming “MMDD” is a typo and you use “MM-DD” this script will do it. Otherwise you’ll have to adjust it.

-- Set creation date based on name "# Title - YYYY-MM-DD-HHmmss”

tell application id "DNtp"
	try
		set theRecords to selection of viewer window 1
		if theRecords = {} then error "Nothing selected."
		
		repeat with thisRecord in theRecords
			set theName to name of thisRecord
			set theFileName to filename of thisRecord
			
			if theName = theFileName then
				set revPath to reverse of characters in theFileName as string
				set theSuffix to reverse of characters 1 thru ((offset of "." in revPath) - 1) in revPath as string
				set theName to characters 1 thru -((length of theSuffix) + 2) in theName as string
			end if
			
			set theCreationDate to creation date of thisRecord
			
			try
				set seconds of theCreationDate to (characters -1 thru -2 in theName as string) as integer
				set minutes of theCreationDate to (characters -3 thru -4 in theName as string) as integer
				set hours of theCreationDate to (characters -5 thru -6 in theName as string) as integer
				set day of theCreationDate to (characters -8 thru -9 in theName as string) as integer
				set month of theCreationDate to (characters -11 thru -12 in theName as string) as integer
				set year of theCreationDate to (characters -14 thru -17 in theName as string) as integer
				
				set creation date of thisRecord to theCreationDate
			end try
		end repeat
		
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell