Need way to export infinite subdirectory file / folder listing

Discussion in 'Mac Basics and Help' started by theLemur, Oct 30, 2011.

  1. theLemur macrumors regular

    Jan 6, 2008
    I have a massive self-developement audio library. I would like to take that folder (which is divided into categories, then by authors, then by programs) and get a list of all recursive subdirectories and files in a text file that I can send to a friend to share my library.

    Any suggestions?
  2. PhilRodford macrumors newbie

    Nov 1, 2011
    Open a terminal window
    navigate to the top directory (folder) you want to list

    For non UNIX users use the command 'cd name' to change directory where 'name' is the name of the directory, type 'pwd' to find out where you are.

    Type 'ls -R' to do a recursive list and check that that is what you want.

    Type 'ls -R > filelist'

    this will create a file in your current directory called filelist, use a different name if you want to.

    Check it by typing 'cat filelist'

    You should be able to attach the file to an EMail message.
  3. theLemur thread starter macrumors regular

    Jan 6, 2008
    Problem is that I have a lot of subdirectories, and it would take hours and hours to do that for each one. I think there used to be a DOS command that would list EVERYTHING under a directory, I can't remember the command line, but I need something like that.
  4. chown33 macrumors 604

    Aug 9, 2009
    PhilRodford said the listing is "recursive". Which means it will list the contents of every subdirectory. And the contents of every subdirectory of every subdirectory. And so on. Until everything has been listed. If you think you have to manually go into every subdirectory, then you don't understand what "recursive" means.

    PhilRodford also gave you specific commands to try. He also said "check that that is what you want".

    Did you try what he gave you? If so, did it produce what you want?

    If you didn't try it, then you should do so, so you can see what it does. If you try it and it doesn't do what you want, then by all means, post again with a specific description of why it's not what you want. But if you haven't tried it, and you don't know what "recursive" means, then complaining is premature.
  5. theLemur thread starter macrumors regular

    Jan 6, 2008
    It was late when I read it, so I missed that part and thought it was just a directory listing. Thank you for spending your time correcting me.
  6. dahodd macrumors newbie

    Jul 21, 2011
    Windows version of subdirectory listing...

    The command for this in Dos are "dir/s" if you should refer to it again.
  7. samh macrumors 6502

    Oct 29, 2009
    In this case you want a Terminal command, not a DOS command. "DOS" and "command-line" or "terminal" are not interchangeable.

    DOS is a specific operating system -- well, a group of operating systems -- which has nothing to do with Mac OS.

    fwiw, if you want the final result to be sortable, I'm sure you could play around with importing the doc into Numbers or Excel and playing with that...
  8. ozaz macrumors 65816

    Feb 27, 2011
    I'd like to accomplish something like this, but the formatting of the resultant file is not what I want.

    I want to create a text file formatted with the full path of each file on different lines




    I don't want any information about the files, just a list of full path names.
    Can the terminal command be altered to do this?

    Also, is there a simple app that does this sort of thing? I'm not good at remembering terminal commands and syntax.
  9. chown33 macrumors 604

    Aug 9, 2009
    Assuming the User in the above is your actual user name, try this:
    find ~/Documents -type f >~/Desktop/docs.txt
    The output will be in the text file "docs.txt", located on your desktop.

    If the above doesn't produce the output you want, then post a sample from the actual docs.txt file, and explain why it's not what you want. If the above produces an error message, copy and paste the actual text of the message into a reply.

    Copy the above command to the clipboard. Paste it into a window. It runs, producing output in docs.txt on your desktop.

    Then open a new file in Paste the command into that window. Save as "Commands for listing Documents folder".
  10. ozaz macrumors 65816

    Feb 27, 2011
    Thanks. That did what I wanted.
    How do you exclude hidden files? I am getting .DS_Store in the output
  11. chown33 macrumors 604

    Aug 9, 2009
    Try this.
    find ~/Documents -type f -not -name '.*' >~/Desktop/docs.txt
    It excludes all files whose name starts with dot. This will match (and thus exclude) files other than ".DS_Store".

    It will not exclude files that are hidden because they have their 'hidden' flag set. If you don't know what the hidden flag is, this shouldn't be a problem.
  12. ozaz macrumors 65816

    Feb 27, 2011
    Thanks, that did the job. I also managed to do it by creating an automator workflow that prompts me to select the folder I want to create a listing for. The actions I used were:
    1. ask for finder items (folder option)
    2. get folder contents (with repeat for each subfolder option invoked)
    3. new text file

Share This Page