Automater / AppleScript File Listing and Size Output

Discussion in 'Mac Programming' started by rf2209, Nov 26, 2014.

  1. rf2209 macrumors newbie

    Joined:
    Nov 26, 2014
    #1
    Hi,

    I have previously used windows and am starting out with a mac, for a project I am working on I require an output text or spreadsheet file that shows the following:

    all folders, sub folders and files on a certain volume in a list with the parameters of last opened or lost modified before 1 Jan 2013

    I started in automator but couldn't work out how to control the parameters so have moved to applescript but Im struggling.

    Any help much appreciated
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Personally, I'd take a look at the command line "find" command. Open up your Terminal and type:

    man find

    ...to see the manual pages for "find". For example, if you're interested in listing all files in a folder located at /Library/Preferences then you'd use the command:

    Code:
    find /Library/Preferences -type f
    
    The '-type f' bit tells find that we're only interested in files. Filtering by file age can be fiddly, but it's doable. Look at the man pages for options (specifically 'time'). There's a good discussion of finding files by date here:

    Code:
    http://www.unix.com/tips-and-tutorials/20526-mtime-ctime-atime.html
    
    Once you're happy with the results you're getting, you can write these to a file like this:

    Code:
    find /Library/Preferences -type f > ~/Desktop/results.txt
    
    Hope that's of some help!
     
  3. rf2209 thread starter macrumors newbie

    Joined:
    Nov 26, 2014
    #3
    Hi,

    Thank you very much for your help, much appreciated.
     
  4. briloronmacrumo macrumors 6502

    briloronmacrumo

    Joined:
    Jan 25, 2008
    Location:
    USA
    #4
    Disk usage ( du ) command can be helpful. Output can be redirected to a file per Superscape's last code post.

    List files and sizes for Library caches:
    Code:
    sudo du -sh /System/Library/Caches/*
    
    redirecting results to a file:
    Code:
    sudo du -sh /System/Library/Caches/* > ~/Desktop/results.txt
    btw: du does not require sudo but some directories might require authentication.
     

Share This Page