-- ChangeCreationDate -- version 1.0, Daniel A. Shockley (http://www.danshockley.com) -- version 1.1 Modified by Lantrix (http://techdebug.com) - functionality now changed to set Modified date of any file to the Creation Date -- idea suggested by spacericker9k on macosxhints.com, at: -- http://www.macosxhints.com/article.php?story=20060703160750583 on run -- Display intro display dialog "This script will change the Modified time on selected files to the Created time" -- some coding formatted to keep the individual lines shorter set dialogMsg to "Choose a folder of files to change, or file(s)?" set buttonChoices to {"Cancel", "Folder", "Files"} set openChoice to button returned of (display dialog dialogMsg buttons buttonChoices default button "Files") if openChoice is "Files" then set chooseFileDialog to "Choose the file(s) you want to change:" set fileList to choose file with prompt chooseFileDialog with multiple selections allowed else if openChoice is "Folder" then set oneFolder to choose folder with prompt "Choose the folder whose files you want to change:" tell application "Finder" set fileList to (files of oneFolder) as alias list end tell end if changeCreationDate(fileList) end run on open someItems -- someItems could be files or folders - will only process FILES -- Display intro, to stop accidental drops -- version 1.1 Lantrix (http://techdebug.com) set dialogMsg to "This script will change the Modified time on your dropped files to the Created time" set buttonChoices to {"Cancel", "OK"} set openChoice to button returned of (display dialog dialogMsg buttons buttonChoices default button "Cancel") if openChoice is "OK" then changeCreationDate(someItems) end if end open on changeCreationDate(fileList) -- version 1.0, Daniel A. Shockley (http://www.danshockley.com) repeat with oneItem in fileList -- for now, just handle files, not folders tell application "Finder" -- version 1.1 Lantrix (http://techdebug.com) -- this "tell" sets newCreationDate to the Creation Date of the file. -- We no longer ask user for date set newCreationDate to creation date of file oneItem end tell set creationDateString to year of newCreationDate as string set creationDateString to creationDateString & text -2 thru -1 of ("0" & getMonthNum(newCreationDate) as string) set creationDateString to creationDateString & text -2 thru -1 of ("0" & day of newCreationDate as string) set creationDateString to creationDateString & text -2 thru -1 of ("0" & hours of newCreationDate as string) set creationDateString to creationDateString & text -2 thru -1 of ("0" & minutes of newCreationDate as string) set creationDateString to creationDateString & "." & text -2 thru -1 of ("0" & seconds of newCreationDate as string) if folder of (info for oneItem without size) is false then set shellCommand to "touch -t " & creationDateString & " " & quoted form of POSIX path of oneItem set logMsg to ("Changed creation date of file '" & oneItem as string) & "' to " & newCreationDate as string logConsole("changeCreationDate", logMsg) do shell script shellCommand end if end repeat -- version 1.1 Lantrix (http://techdebug.com) -- Display finished notice set dialogMsg to "Date Change complete" set buttonChoices to {"OK"} set openChoice to button returned of (display dialog dialogMsg buttons buttonChoices) end changeCreationDate on getMonthNum(theDate) -- French Vanilla, by Emmanuel LŽvy --set theDate to the current date --or any other date copy theDate to b set the month of b to January set monthNum to (1 + (theDate - b + 1314864) div 2629728) return monthNum end getMonthNum on logConsole(processName, consoleMsg) -- version 1.5 - Daniel A. Shockley, http://www.danshockley.com -- 1.5- uses standard date-stamp format set timeStamp to do shell script "date +\"%Y-%m-%d %H:%M:%S\"" set hostName to do shell script "hostname -s" & space set logMsg to (return & timeStamp & space & hostName & space & processName & ":" & space & consoleMsg) set shellCommand to "echo" & space & quoted form of logMsg & " >> /dev/console" do shell script shellCommand end logConsole