29 December, 2009 at 7:09 pm
filed under Techniques
Tagged osx, unix
Every now and then you’re really grateful OSX is essentially Unix with a smiley face. Since that allows you to easily get under the hood for those “should be simple” tasks.
For this one, I needed to produce a list of files within a collection of folders which, for demonstration purposes, we’ll call media files.
This is easy:
cd (there’s a space after ‘cd’)ls -RF > list.txtThis will produce a list of all files in the directory, and subdirectories, as list.txt in the starting directory. Feel free to give it a more useful name.
So now you’ve got a list of all the files in the folders. But if you want to find a subset based on filename (say, for example, the list of media files identified in the title as being 2009 releases) then use the wonders of unix to ‘pipe’ the file list to GREP to filter it before writing the file:
ls -RF | grep '2009' > 2009.txt
This will produce a list of only those files with ‘2009′ somewhere in the title.
Armed with LS and GREP you can pretty much produce any subset of any folder set you require. Enjoy!
no comments
RSS / trackback