Output a text list from Folders

Discussion in 'macOS' started by efoto, May 11, 2005.

  1. efoto macrumors 68030

    Joined:
    Nov 16, 2004
    Location:
    Cloud 9 (-6)
    #1
    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.
     
  2. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #2
    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... :)
     
  3. efoto thread starter macrumors 68030

    Joined:
    Nov 16, 2004
    Location:
    Cloud 9 (-6)
    #3
    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!
     
  4. efoto thread starter macrumors 68030

    Joined:
    Nov 16, 2004
    Location:
    Cloud 9 (-6)
    #4
    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.
     
  5. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #5
    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...
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    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).
     
  7. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #7
    Here is one place to start if you want to learn more about Terminal.

    Enjoy.
     
  8. efoto thread starter macrumors 68030

    Joined:
    Nov 16, 2004
    Location:
    Cloud 9 (-6)
    #8
    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:
     
  9. whocares macrumors 65816

    whocares

    Joined:
    Oct 9, 2002
    Location:
    :noitаɔo˩
    #9
    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.
     
  10. efoto thread starter macrumors 68030

    Joined:
    Nov 16, 2004
    Location:
    Cloud 9 (-6)
    #10
    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.
     

Share This Page