Use the UNIX redirect command to create lists

Jun 17, '03 09:20:00AM

Contributed by: danyel

I read the hint about the export playlist feature in iTunes, and I want to share the way I create this list. I usually put all my MP3s in just one folder, so I use the Terminal to make a list using the UNIX "redirect output" flag, >, which redirect the standard output to a file (a textfile). To do this, you don't have to be a guru using the Terminal, just use cd /path/to/folder to navigate to the folder from which you want to make the list. Once you are there, type:

ls >> textfile.txt
If there are other sub-folders and you want to list their contents, too, you can use (but be careful, as it will list all sub-folders):
ls -R >> textfile.txt
The textfile is created in the current directory (unless you included a full path before textfile.txt). If the file already exists, it will make an append to that file (due to the use of two redirect symbols). However, if you use > instead of >>, the file will be overwriten instead of appended. This is an easy way of making a list of anything on Mac OS X ... or any Unix system.

[robg adds: Yes, this is a basic UNIX hint, but it's quite useful and I don't think we've covered the functionality before. You can use the redirect symbols on anything that dumps output to the screen -- ps -ax > running_stuff.txt will create a text file of the ps output, for example.]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030613013238228