I’m trying to retrieve the creator type from a file, and i’m kinda half way there i think.
Using the NSFileManager i have retrieved a whole list (its probably a record cause its something to do with the NSDictionary i think ) of info but it returns that info mostly in Numbers
i now believe from reading the documentation that you can use an NSDictionary Method to retrieve the actually Creator code.
The creator code for a pdf is “CARO”
in Applescript i use this:
tell application "Finder" to get creator type of (choose file)
-- "CARO"
But this isn’t working for me so i’ve used this:
set theFileType to fileManager's attributesOfItemAtPath_error_(POSIX path of theFolder, missing value)
this returns :
I need to now convert the number which is associated with “NSFileHFSCreatorCode” or “NSFileHFSTypeCode”
i’ve tried a million combinations of code, based on variations of what it says in the documentation here:
In the process i have once again confused the hell out of myself which ain’t helping,
so if anybody ou there can point me in the right direction on this, i may even be looking in the totally wrong place
then i would be appreciative of the help.
Thanks shane that worked, i wasn’t aware that this stuff is depreciated i was gonna use it to check for files with a certain creator code but i may look at a different route now.
What about the size of a folder? It returns the same number every time for all the folders I try the method on… Is there a way to get the total size of a folder like the one in the Finder Info window?
Gracias!
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)
You have to do it the way the Finder presumably does: get the size of every file in the folder. Start with NSFileManager’s enumeratorAtPath: method, or perhaps enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:.
Yeah, I agree. It is slow with long lists. Usually I use repeat with currentItem in listOfItems instead of repeat with currentItem from 1 to (count of items in listOfItems). Found out by experimenting on a 2000+ items list that it was 8 times faster this way.
So far, the finder way is quite fast. I don’t think i’d be saving tens of seconds by going the obj-C way for less than a 100 items… I could be wrong though.
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)