File lists

J. Landman Gay jacque at
Fri Jul 16 13:10:19 EDT 2010

Medard wrote:
> Jim Ault <jimaultwins at> wrote:
>> revMacFromUnixPath("/usr/bin/stuff") -- returns "usr:bin:stuff"
> OK, that's better :-)
> and how about adding the volume name?

I used revMacFromUnixPath in my final handler. It not only manages the 
slash/colon substitutions but it also knows when to add the volume name.

Just for the record, here are the handlers I ended up with for use in OS 
X. The first one is similar to Ken Ray's posting, but I changed it 
slightly since not all valid files start with the word "file". This 
version catches textclippings and other types of OS X files that don't 
return with the word "file" attached:

-- get a list of all OS X files in a folder

function getFiles pFolder
   put revMacFromUnixPath(pFolder) into pFolder
   put "tell application" && quote & "Finder" & quote & cr & "files of 
folder" \
       && quote & pFolder & quote & cr & "end tell" into tScript
   do tScript as "applescript"
   put the result into tFiles
   replace comma with cr in tFiles
   repeat for each line l in tFiles
     get the number of words in char 1 to offset(quote,l) of l
     put word it of l & cr after tList
   end repeat
   replace quote with empty in tList
   return tList
end getFiles

-- see if a file path is a valid OS X document file:

function isDocument pPath
   set the itemdel to slash
   put last item of pPath into tDoc
   put revMacFromUnixPath(item 1 to -2 of pPath) into tFolder
   put "tell application" && quote & "Finder" & quote & cr & "item" \
       && quote & tDoc &quote && "of folder" &&quote& tFolder & quote & 
cr & "end tell" into tScript
   do tScript as applescript
   return word 1 of the result = "document"
end isDocument

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list