In the initial section of this post, I leave the AppleScript code formatted as it would appear in the Script Editor pane to show that keywords, statements and other expressions that appear in blue in the Script Editor are part of the AppleScript language and syntax and knowing that is helpful when writing scripts.
Let’s start with this statement:
set theFile to choose file with prompt “Please select a file:”
set fileInfo to info for theFile
The first statement get the full path to a document, in this case, “My Document.cwk” and the second, all of the information on the document:
{name:”My Document.cwk”, creation date:date “Monday, June 8, 2009 8:24:34 AM”, modification date:date “Monday, June 8, 2009 8:24:34 AM”, icon position:{0, 0}, size:1.9715E+4, folder:false, alias:false, package folder:false, visible:true, extension hidden:false, name extension:”cwk”, displayed name:”My Document.cwk”, default application:alias “Macintosh HD:Applications:AppleWorks 6:AppleWorks 6.app:”, kind:”com.apple.appleworks.document”, file type:”CWWP”, file creator:”BOBO”, type identifier:”com.apple.appleworks.cwk”, locked:false, busy status:false, short version:”", long version:”"}
This all looks pretty intense, but some of the info is only relevant for certain types of files (folders as opposed to documents, for instance) and although Applescript will return info in the form of an empty string or ‘false’ on some items, the info is usually of little use unless you are targeting the right file type.
With that in mind, let’s look at some of the results that are relevant for the file “My Document.cwk” which is an AppleWorks Document:
Creation Date:
set filedate to creation date of (info for theFile) result–> date “Monday, June 8, 2009 8:24:34 AM”
Modification Date:
set fileModDate to modification date of (info for theFile) result–> date “Friday, July 17, 2009 10:48:20 PM”
File Size:
set fileSize to size of (info for theFile) result–> 1.9715E+4
Miscellaneous Info:
set isFolder to folder of (info for theFile) –all of these return a boolean (true or false) value and some are only relevant when the target is a folder.
set isAlias to alias of (info for theFile)
set isPackage to package folder of (info for theFile)
set isVisible to visible of (info for theFile)
set extHidden to extension hidden of (info for theFile)
set fileLocked to locked of (info for theFile)
The following, I find the most useful for what I usually need to do:
set extName to name extension of (info for theFile) –> result: “cwk”
set displayName to displayed name of (info for theFile) –> result: “My Document.cwk”
set defaultApp to default application of (info for theFile) –> result: alias “Macintosh HD:Applications:AppleWorks 6:AppleWorks 6.app:”
set fileKind to kind of (info for theFile) –> result: “com.apple.appleworks.document”
set fileType to file type of (info for theFile) –> result: “CWWP”
set fileCreator to file creator of (info for theFile) –> result: “BOBO”
–> result: “com.apple.appleworks.cwk”
set fileTypeIdentifier to type identifier of (info for theFile)
Just something to note on a similar subject:
short version of (info for theFile) and long version of (info for theFile) are mainly only relevant for applications such as this case with AppleWorks 6:
“AppleWorks 6.2.4 for Mac OS X Copyright Apple Computer, Inc. 1991-2002″ –> the long version of AppleWorks 6
If you get the info for a file and place it into a variable, then you can use that to simplify and extract specific items of the info variable and place them into their own specifice variables such as this one using our original document:
set theFile to choose file with prompt "Please select a file:"
set fileInfo to (info for theFile)
set fileDate to creation date of fileInfo
Here’s an ‘all purpose’ script to open a document. It gives you some idea of how you can use data from a documents ‘Get Info’ window. What is shown here will work with most documents, provided you have the application on your desktop.
set theFile to choose file with prompt "Please select the file you want to open:"
set fileInfo to info for theFile
set theFile to theFile as alias
set defaultString to ((default application of fileInfo) as string)
set AppleScript's text item delimiters to ":"
set AppString to (text item -2 of defaultString)
set AppleScript's text item delimiters to "."
set theApp to (text item -2 of AppString)
openDoc(theFile, theApp)
on openDoc(fileName, defaultApp)
tell application defaultApp
activate
open fileName
end tell
end openDoc
Contact me if you have any questions or comments at: hyperscripter@gmail.com or http://twitter.com/hyperscripter.


















Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your site? My website is in the exact same area of interest as yours and my visitors would definitely benefit from some of the information you present here. Please let me know if this okay with you. Thanks a lot!
I simply want to say I am just very new to blogging and definitely savored this blog. More than likely I’m going to bookmark your blog post . You absolutely come with incredible article content. Many thanks for revealing your blog.
Very easily, your content is in fact by far the most practical for this valuable area. To be sure using all ones studies and definitely will desperately expect to have your impending messages. Declaring appreciate it won’t only do, for that fantasti k lucidity in your publishing. I’m going to direct try to find your current feed to have well informed of your changes. Reliable get the job done and far achievements inside your business deals. Take care,
Thank you for sharing your ideas about this. Keep it up!
There is absolutely simply better way to spruce up your kitchen area than with a bar along with a handful of fabulous looking bar stools. Never forget that the bar stools are actually what will set it all off.
Paintball has got to be one of the most pleasurable and exciting games to play that I’ve ever experienced. There’s a really good reason why it is getting so popular. If you have not tried it , then you should give it a go.
Thanks, You probably haven’t purported to do this, however I believe you could have could express the mind-set that lots of patients are really in.
Congratulations on having essentially the most luxurious community forums Ive come upon in some moment in time! Its just incredible simply how much you could reduces from another thing just because of how visually lovely it really is. Youve compiled an excellent blog house –great image, video clips, describe. This is definitely a must-see blog!
Someone unavoidably help to construct brutally blog posts I’d state. This is certainly the really most importantly time I frequented your online site site thus far? I shocked using the analysis individuals fabricated to create this approach certain put up magnificent. Shining method!
It a new idea! Just wanna say thank you for your information you encounter posted. Just continue composing one of these post. I am about to a loyal reader, thanks a lot.
Thanks, You probably haven’t supposed to do this, however I believe you have managed to express the mind-set that many of individuals are really in.
My hope is the idea that some participants in our community will probably be attracted to shared their scholarly work for possible presentation along at the conference.
I love what you guys are up too. Such clever work and coverage! Keep up the awesome works guys I’ve included you guys to our blogroll.
I like what you guys tend to be up too. This kind of clever work and exposure! Keep up the amazing works guys I’ve included you guys to my personal blogroll.
My cousin instructed I accidentally might like this website. He seemed to be entirely right. This post genuinely made my day. You cannot imagine simply how much time frame I had developed depleted because of this information! Merit
My hope is because some participants in our community will be attracted to submitting their scholarly get a job with possible presentation along at the conference.
Whilst Twitter is normally used by individuals to be in close reference to buddies and also loved ones folks, it’s a growing number of often getting used simply by companies and organizations in an effort to marketplace items and services. The likes regarding Dell as well as Jet Glowing blue utilize Twitter to market their solutions along with Barack Obama and also John Edwards utilized Twitter being a advertising signifies through the campaign trail.
I became some great info here. I do think that if a greater number thought of it that way, they’d have a better time get the hang ofing the difficulty.
Thanks, You probably haven’t purported to achieve this, however I believe you have got was able to express the mind-set that many of individuals are in.
I am really fanatic of your respective blog…will get answered adequately asap. I’m really happy along with your specific writing skills and likewise with the layout on your web site. Is this a paid theme or did you customise it by yourself? Anyway maintain the nice high quality writing, it’s infrequent to ascertain a beautiful weblog of this nature 1 today..