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

efoto

macrumors 68030
Original poster
Nov 16, 2004
2,624
0
Cloud 9 (-6)
Sorry if this belongs in the basics, I wasn't sure.

I was curious if there is a somewhat simple way to output a list or directory of titles from a given folder of documents/songs/files/etc.

Basic use example: iTunes music folder, I want to output all the artist folders (the way iTunes organizes them) into a simple text list so its easier to so what I have and what I want to get.
Thanks in advance, as always.
 
In terminal:

cd /path/to/folder/in/question
ls > /path/to/textfile.txt

or just: ls /path/to/folder/in/question > /path/to/textfile.txt

Edit: You don't have to make the textfile in advance, because it is made for you with the 'ls' command. Note that if you have a file with the same name as you give it on that location it will be overwritten, no questions asked...

Edit 2: There's an easier way if you're not comfortable with Terminal: just find the folder in Finder, mark ALL the items in the folder, choose Edit -> Copy (cmd-C) and open a text file (I prefer TextWrangler) and in that choose Edit -> Paste (cmd-V) and a text-only list will be pasted in... :)
 
Mitthrawnuruodo said:
Edit 2: There's an easier way if you're not comfortable with Terminal: just find the folder in Finder, mark ALL the items in the folder, choose Edit -> Copy (cmd-C) and open a text file (I prefer TextWrangler) and in that choose Edit -> Paste (cmd-V) and a text-only list will be pasted in... :)

Well that sure is easy, I should have thought of that. Oh well....
I will try the Terminal one too, just because I want to do more in Terminal for the sake of using it, or at least trying.

Thanks!
 
Instead of starting a new short thread....what is the terminal equivalent for "dir" command in windows 'terminal' that gives a listing of contents for a specified folder?
I tried 'help' and 'help name' in an attempt to find it myself, but alas I have not.

Edit: I guess helpful too would be how to do a space in terminal. I know some programs view spaces as underscores "_", but that doesn't seem to take.
 
It's the above mentioned ls command

ls : lists all (non-hidden) files folders
ls -l : lists all with details
ls -a : lists also hidden files
ls -la : lists all + hidden with details

Check out man ls for more details...

Edit: You can autocomplete commands/paths with TAB, to avoid the space-problem, or you can use backslash space, '\ ', that will be read as a space...
 
ls = dir as noted above. To use ls (or any other command) on files or folders with spaces in the names you have two options:

1) Escape the bad characters: ls -l My\ Folder\ With\ Spaces

2) Quote the entire name: ls -l 'My Folder With Spaces' (note you can use "name" as well although technically they are different as in most shells double quotes allow for the use of environment variables).
 
Mitthrawnuruodo said:
Here is one place to start if you want to learn more about Terminal.

Enjoy.

Thank you much, seems like a good resource.
Thanks for the explanations too, very helpful. It works great now, funny how typing the proper command makes things go so smoothly :rolleyes:
 
Back on topic :p , a different way to create the file list:

Open folder in Finder, select all files (command + A), copy them (command + C), open desrired application for creating list (Textedit, Excel, etc) and paste (command + V). Voilà - easy, no terminal :)

Of course, terminal is more powerful & useful for more complicated file lists, like a list of all jpeg on the HDD, all files larger than X MB, all files created today. But that a whole different thread subject.
 
Mitthrawnuruodo said:
Edit 2: There's an easier way if you're not comfortable with Terminal: just find the folder in Finder, mark ALL the items in the folder, choose Edit -> Copy (cmd-C) and open a text file (I prefer TextWrangler) and in that choose Edit -> Paste (cmd-V) and a text-only list will be pasted in... :)

whocares said:
Back on topic, a different way to create the file list...

I changed topic because I thought the answer would be quick and easy, as it was. Mitthrawnurudo already mentioned the copy/paste method for an alternative for Terminal, but thanks none the less.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.