Friday, May 26, 2017
  • Index
  •  » OS X Finder
  •  » Has something changed in Mac OS X as far as identifying files by type?

#1 2005-10-12 07:00:53 am

julifos
Administrator
From: Malasa√Īa, Madrid
Registered: 2002-11-20
Posts: 2014

Has something changed in Mac OS X as far as identifying files by type?

Yes and here's the story, according to the official AppleScript site:

While the Mac OS X file system supports file types, its use is optional and some files may not have a file type. They may instead be identified by their filename extension. Scripting routines that previously relied soley on identifying files by their file type property should be augmented to also check for filename extensions.

The following example of a Finder droplet demonstrates how an extension check can be used as a backup for the file type property.

Applescript:

property typeList : {"JPEG", "GIFf", "PICT", "TIFF"}
property extensionList : {".jpg", ".gif", ".pct", ".tif"}

on open theseItems
   
   -- EXAMINE AND PROCESS EACH DRAGGED-ON ITEM
   repeat with i from 1 to the count of theseItems
       set thisItem to (item i of theseItems)
       -- GET THE INFO FOR THIS ITEM
       set the itemInfo to info for thisItem
       if ((folder of the itemInfo is false) and √?¬¨
           (alias of the itemInfo is false)) and √?¬¨
           (the file type of the itemInfo is in the typeList) or √?¬¨
           (my checkExtension(the name of the itemInfo) is true) then
           -- IF THE ITEM IS NOT A FOLDER OR AN ALIAS AND ITS FILE TYPE IS IN THE LIST,
           -- OR IT'S FILENAME ENDS WITH THE CORRECT EXTENSION, THEN PROCESS THE ITEM
           my processItem(thisItem)
       end if
   end repeat
end open

on processItem(thisItem)
   -- PROCESSING ROUTINES GO HERE
end processItem

on checkExtension(thisFilename)
   repeat with i from 1 to the count of the extensionList
       if thisFilename ends with (item i of the extensionList) then return true
   end repeat
   return false
end checkExtension

Offline

 
  • Index
  •  » OS X Finder
  •  » Has something changed in Mac OS X as far as identifying files by type?

Board footer

Powered by FluxBB

[ Generated in 0.031 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)