using terminal to 'get info' on all files in a directory and write a txt file

edited March 2011 in advice
ls -l will give you info on a file. ls -le will give you a little more info, mdls will return the metadata of any given file, image dimensions, author of a word document, etc.

so, i guess you could cd to the folder you want to get info on it's contents.

do this by typing 'cd' in the terminal window, then drag and drop the folder into the window - it will complete the path for you. hit enter, you are now in the right place (probably).

type something like this at the prompt, and hit enter.

ls -lh -RF > ~/Desktop/getinfo_list.txt

if everything goes well, and there is no smoke emanating from the machine, you should now have a text file on your desktop which contains a series of numbers and characters which look like gobbledegook and mean very little to the casual observer.

i changed ls -le to ls -lh, as it gives you more human readable file sizes (kb/mb, rather than b).

is there an easy way to get mdls to work recursively through a directory, rather than just on a per-file basis? seems that ~mdls -R doesn't want to make my life super easy :D

Comments

  • edited 2:51AM
    Yes, you just need to do:

    mdls ./*

    ./ is the current directory and
    * is all files (in current)

    Also, adding to the original, the following will list invisible items as well

    ls -la
  • edited 2:51AM
    ZOMG! nice one, peakstar :D
  • edited 2:51AM
    Noice. Bung this into the toolbox thread please, useful innit!
Sign In or Register to comment.