MacOS – How i can log various information of files in directory

macosunix

I'm looking for a way to get the following information via AppleScript:

  • all the information ls provides including the creation date/time of a file or folder
  • MD5 hash, Finder labels and Finder/Spotlight comments

into an output like

46737077 drwxr-xr-x 2 Jonas 68 Oct 4 15:39:34 2012 /Users/Jonas/Desktop/test/test.txt 5 md5_here finder_comment_here

What I currently have is some old code which needs tweaking (creation date/time is missing):

do shell script "find -x " & my_path & " -print0 | xargs -0 ls -d -F -P -l -T -a -e -i -o -p -q " & my_path user name "user" password "pin" with administrator privileges

and some basic looping code for the comments/labels

set results_list to "/Users/Jonas/Desktop/test1.txt /Users/Jonas/Desktop/test2.txt"
set comm to {}  
set labels to {}  
repeat with counter from 1 to count paragraphs in results_list  
    tell application "Finder" to set end of comm to comment of item ((POSIX file (paragraph counter in results_list)) as string)  
    tell application "Finder" to set end of labels to label index of item ((POSIX file (paragraph counter in results_list)) as string)  
end repeat  

but now I'm kind of stuck in combining this all together.

Best Answer

I am not sure if you need to have it in this particular way, but why not simply using something like

ls -l > logfile.txt

and add the necessary options to ls if you want it a little bit more specific