I’m porting a large AppleScript to OS X and am trying to replace the functions of Tanaka’s MT List Files and MT List Folders commands. Those were great because you could retrieve a list of files of a particular file type from all sub folders in one line without having to loop or walk thru them. Does anyone know of a way to do this in OS X with the same ease?
I say sort of because the result returns an extra forward slash after the Documents folder (e.g., “/Users/jon/Documents//MyFile.xls”). Also, from this list, if you aren’t passing this to other shell scripts, you’ll probably still need to traverse the list to convert to Mac-style colon delineated paths. Find is very powerful and defaults to go all the way down a directory path to all subfolders. To limit to just the folder specified, add the “-maxdepth 1” flag. Other flags can also be added to find files based on size or date or more powerful regex.
It looks like “POSIX path” is putting a / at the end. In the terminal.app you can use this and it will not give you the double slashes…
find '/Users/myusername/Documents' -name '*.xls'
-->/Users/myusername/Documents/FLDS1.xls
--but if you use ...
/Users/myusername/Documents/ -- it will show the double slashes
-->/Users/myusername/Documents//FLDS1.xls