How to create a list of all the files inside a macOS directory in seconds with TextEdit

Posted:
in macOS edited February 2018
On the rare occasion a list of all of the files within a folder are required, there is a simpler way than manually typing it out or creating a collage of Finder screenshots. AppleInsider reveals how to compile the list using TextEdit.




There aren't many reasons why one would want to create a list of file names, but sometimes it can be quite a useful thing to produce. For example, a developer may want to keep a record of files and folders within a directory when they are producing an app, while those with extensive media collections could require a list based on their archives.

First, open up the folder you want to create the list from, and select all of the files and folders you want to include. Once all of the relevant files and folders are selected, copy the list by either selecting Edit then Copy Items in the menu or the Command-C keyboard shortcut.




Open up TextEdit, Apple's included text editor, and create a New Document. Once it is open, go to Format in the Menu and select Make Plain Text.



Finally, paste the files into the text document by selecting Edit then Paste, right clicking the document and selecting Paste, or by using the Command-V keyboard shortcut. This will paste the entire list of file and folder names into TextEdit.



There is also the option to create the same list that includes the folder path for each item, instead of just the file names. This can be created by dragging the selected files and folders into the TextEdit document, again set to Plain Text, instead of pasting.




If the TextEdit document is kept as Rich Text, the Mac will instead attempt to insert a copy of the documents and folder into the document. By keeping it as Plain Text, only the file and folder names will be pasted.

If you want to use this list elsewhere, be sure to select the pasted text and copy it before pasting in the app you want to use, otherwise you could end up pasting a copy of the folders and files themselves.

Comments

  • Reply 1 of 13
    Apple's implementation of the "pasteboard" as part of the original Mac OS belongs in the unsung achievements in IT hall of fame (if there were such a thing).  So brilliant and versatile.
    philboogiesandorStrangeDaysDr.MOROjony0dysamoria
  • Reply 2 of 13
    The same works in other places where you can copy or drag files. E.g. search results in HoudahSpot. Thus the trick is not limited to files at the top level of a folder. It can also be used to compile a list of files found all over your disk.

    A really cool trick related to the above: hold the command key as you drag a folder or file to a Terminal window. This changes the shell's current directory to that folder or the folder containing the file.

    Many document based applications show a proxy icon found next to the document name in the title bar.  Drag this to TextEdit (or a plain text editor like BBEdit) to get the file path. Command-drag it to Terminal to go to the document's parent folder.
    dysamoria
  • Reply 3 of 13
    1) I cannot believe I'm seeing this article.

    2) I think it's easier to simply paste by Command-Option-Shift-v instead.

  • Reply 4 of 13
    Why not just run "ls -R > filename.txt" in a terminal window? I don't get it... UPDATE: Upon re-reading my comment, I can see how it can be misconstrued as rude or snide, and my "geekiness" can be offensive to some. Well, sorry for that. For the record, I was genuinely confused by the approach suggested in the original post. But sure, I can see how some people may be more comfortable with TextEditor.
    edited February 2018 phone-ui-guy
  • Reply 5 of 13
    Mike WuertheleMike Wuerthele Posts: 4,567administrator
    klock379 said:
    Why not just run "ls -R > filename.txt" in a terminal window? I don't get it...
    Because not all Mac users want to use the terminal. AppleInsider is not just for you.
    sandorDr.MOROjony0dysamoria
  • Reply 6 of 13
    klock379 said:
    Why not just run "ls -R > filename.txt" in a terminal window? I don't get it...
    Why are nerds so insufferable?

    no wonder people enjoyed beating us up in high school.
    jony0viclauyycdysamoria
  • Reply 7 of 13
    sandorsandor Posts: 523member
    1) I cannot believe I'm seeing this article.

    2) I think it's easier to simply paste by Command-Option-Shift-v instead.


    I've got TextEdit set to open new files as plain text, so command-V works perfectly.

    This is also my preferred method of stripping formatting from text copied from the web, Word, etc (specifically copying citations from Pubmed, etc)
  • Reply 8 of 13
    Awesome tip! Never knew. Will remember this when needed.
    Yeah, not everyone is a Mac Genius nor Mac Geek nor Mac Nerd (nothing bad of any of these, though...), even if using Mac since the first PowerMac like me. ;)
    (I doubt there's a Mac power-user that knows EVERYTHING Mac...)
    "All Inclusive" and "Universal Access", the way to go!
    Knowing that you do not know everything is the start of getting smarter.
    No question is a dumb question. (unless asked repeatedly...)
    Thanks!
    edited February 2018
  • Reply 9 of 13
    My suggestion: use the command-line:

    cd the/directory
    ls -1

    (that's a "dash" and then a "one" after ls)
  • Reply 10 of 13
    1) I cannot believe I'm seeing this article.

    2) I think it's easier to simply paste by Command-Option-Shift-v instead.

    yep. and by using this step you can even paste the files list on another writing app such as pages.
  • Reply 11 of 13
    Thank you so much.
    This helped me great deal.
    Appreciate it.
  • Reply 12 of 13
    macguimacgui Posts: 1,248member
    friedmud said:
    (that's a "dash" and then a "one" after ls)
    And that's a reason not to use command line.

    Cmd-C, then Cmd-V, done. I've done as shown in the article for years. The seconds saved by using other methods would probably save at least 5min a year. I'm good, thanks.
    dysamoria
  • Reply 13 of 13
    dysamoriadysamoria Posts: 2,138member
    Nice tip. Thanks AI. I've liked these Mac OS tips of late. 

    Also related to this tip: when in a file open/save dialog, you can drag & drop a folder or file from Finder to the dialog window/sheet to target exactly where you want to be instead of navigating to there inside the dialog, when you already have the appropriate location open in a Finder window.
    macguimariowinco
Sign In or Register to comment.