File lists - sort of a solution

J. Landman Gay jacque at hyperactivesw.com
Mon Jul 12 14:04:01 EDT 2010


I've found a semi-reliable solution to the OS X file list issue by using 
an AppleScript. There are some complicated shell tricks I could have 
done, but they require far more work than the AppleScript, so this is 
what I'm doing now:

function getFiles -- assume directory is set
   put shell("ls -AF") into tFiles
   filter tFiles without ".*" -- the "A" flag doesn't strip .DS_Store :(
   filter tFiles without "*.app/" -- remove apps
   filter tFiles without "Icon" & numToChar(13) -- user folder icons
   repeat for each line l in tFiles
     if last char of l <> slash then -- regular file
       put l into tFile -- to check for shell symbol markers
       if last char of tFile is in "*@=%|"
       then delete last char of tFile
       if there is a file tFile then -- in case removing markers changed 
the name
         put tFile & cr after tList
       end if
     else -- bundle or folder; remove user folders
       if isPackage(l) then
         put char 1 to -2 of l & cr after tList
       end if
     end if
   end repeat
   return tList
end getFiles

function isPackage tPath
   put "tell application" &&quote& "System Events" &quote&& \
       "to get package folder of alias POSIX file" &&quote& \
       tPath &quote into tScript
   do tScript as "applescript"
   return the result
end isPackage

It still needs some refinement but it works most of the time. It does 
not catch old Rosetta apps that aren't bundles, so those get put into 
the list. It does not catch Icon files that aren't followed by a 
carriage return. It probably doesn't catch other stuff either, but it 
gets the main things.

I've opened a QCC enchancement request asking for a better way to get 
package-based files on OS X:
<http://quality.runrev.com/qacenter/show_bug.cgi?id=8853>

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list