Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RumorConsumer

macrumors 68000
Original poster
Jun 16, 2016
1,639
1,153
Hello!

I am wondering if somebody could whip me up an app or script that scans a directory recursively and prints the output to a file.

I want to know size, created date, modified date, if its a folder how many items there are, and then info for each file. my goal is to make a text file with a full directory accounting. Everything Finder would be able to tell you. Anybody know this one off the top or know an app that can do?
 

nothingtoseehere

macrumors 6502
Jun 3, 2020
455
522
Alas, I do not have a full AppleScript at hand that would exactly do what you want. Maybe there is something outside; I usually google "Applescript" followed by the solution I am looking for. This helps me at least to get some ideas.

If you want to script yourself, here a beginning:

AppleScript:
tell application "Finder"
    set x to target of window 1 as alias
   
    set the_files to list folder (x)
   
end tell

These few lines only return a list of the files in the folder that is currently open in the Finder. But of course, many more informations can be extracted. When I want to generate a text file from Applescript, I mostly use TextEdit as it is simple and scriptable but Pages would work also.
 

Red Menace

macrumors 6502a
May 29, 2011
583
230
Colorado, USA
Getting information is the easy part, putting it into a usable form can be a pain. There are extended attributes, spotlight, exif, bundle info, etc, but the item list should probably be narrowed so that you don’t wind up with a wall of text for each item.

Check out the ls man page - something like the following should get you started:

Code:
ls -lhART /path/to/source_dir >> /path/to/text_file
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.