hi
I’ve been trying to find out why the following script won’t work on OS X Finder:
tell app “Finder”
make new folder at insertion location
end tell
I believe this worked on OS 9 (or before).
I know, I can do the following to make it work:
set folderLoc to insertion location
make new folder at folderLoc
but I want to know if this is a bug or a feature and if there are any other such instances with OS X FInder.
Also is there any way smart way to get the number of year, month, date from current date?
right now, I am doing
set {theYr, theMt, theDy} to {year,month,day} of (current date)
but this of course would give me theMt=“June”
Instead of that, I I want to get theMt =6
I know I can coerce it like set theMtNum to theMt as number
but it would look smart if I can have one line which will get all three numbers out of current date.
As to part 2 of your query, there are tons of date formatting scripts around (try the search feature, the FAQ, Script Builders & Code Exchange) and NG and AK will be happy to chime in, I’m sure.
In regards to to part 1, AppleScript is usually very kind and adds some missing code for you (which is why the event log looks so much more verbose than your actual code) but sometimes it falls down on the job and you need to add the code that it fails to put in for you. In this case, it’s the word “get”:
Generally, if the Finder isn’t behaving the way you think it should, try adding the explicit “get” and chances are things will start to work more smoothly.
As Camelot says - and if you have Panther - you can coerce the month to integer. If you’re desperate for it to “look smart” in one line, you could write it like this:
tell (current date) to set {theYr, theMt, theDy} to {year, its month as integer, day}
If your next question involves leading zeros or Jaguar, you’ll more than one line.
I’d never heard of the Finder’s ‘insertion location’ either - but there it is, large as life, in all my Finder dictionaries: