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

stefpos007

macrumors newbie
Original poster
Nov 28, 2010
1
0
Can anybody help me create a txt file of all of the files that reside on an external hard drive? Even including file size, date last modified.

I have many hard drives and it would be nice to be able to have a txt file that I could open and search for a file name and by doing so know what hard drive the file lives on. I know there is DOS ways to do this on PC's but I don't know how to do it on a mac.

Any ideas??

Cheers!
 
You're looking for the ls command under Unix. For example:

Code:
ls -l ~/Desktop/some_folder

will print out all files in that folder, permissions, groups, size, date, and some other bits of information. Go to this page for a list of options you can use. It won't take much more effort to write a shell script that'll dump that information into a text file.
 
Sorry for the double post, but here's a quick little script that'll output the ls command to a text file. It doesn't respect newlines for some reason, so you'll have to fiddle with it a bit to get something besides a long string of information.

Code:
FILES=$(ls -o /Volumes/SOME_DRIVE)
echo $FILES > ~/Desktop/files.txt

The -o doesn't print out group names, but does the same as the -l option. If you want all the info, use -l instead. The location of the drive should be pretty straightforward. The above code will create a txt file (and overwrite one of the same name!!) and dump the output of the ls command into it. You can change this to create the file wherever you'd like (the ~ denotes your Home folder). Hope this gets you started on the right track.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.