OK, this is a newbie type question, but my search for “creation” didn’t give me any usable results.
I am finally sitting down to learn AppleScript and to write the script I’ve had in mind for a few years. At the heart of the script will be getting the CreationDate of a file (in some cases) or a CreationDates of each file in a folder of files (in other cases). I will then be creating a text strings based on that. I’ve already got the date-to-text-string routines done - minor accomplishment
I believe I may be asking for 2 things:
How do I get the Creation Date from a file reference?
How will this differ for a folder full of files?
I’ll be verifying file type &/or extensions, but figure the creation date part will get me pointed in the right direction.
Getting the creation date (as well as many other properties of a file or folder) is pretty easy.
Check the Standard Additions dictionary for ‘info for’. You’ll see it returns a ‘file information’ class which has all the info you’re looking for.
So, given a file:
set myFile to (choose file)
You can get info on that file:
set file_info to info for myFile
and now you can get its creation date (or anything else you want):
set file_creation_date to creation date of file_info
set file_extension to name extension of file_info
set file_size to size of file_info
-- etc., etc., etc.
If dealing with a folder full of files you’ll need to iterate through each file in turn. The easiest way to get a list of files in a folder is to use the Finder:
set source_Folder to (choose folder)
tell application "Finder"
set file_list to every file of folder source_Folder
end tell
-- now iterate through the files
repeat with aFile in file_list
set file_info to info for (aFile as alias)
set file_creation_date to creation date of file_info
---etc.
end repeat