How to export a list of files within a volume or folder

finderfoldersterminal

I would like to export a list of files contained in a Volume into legible text, or a spreadsheet document that I can easily share.

Things I have tried so far that didn't work:

TextEdit: If I select all the folders on the volume, for example when the Finder window is presenting them in a column, then Copy then Paste into a Plain Text document, only the names of the folders will be copied, not the contents.
I could present the folder in List format in the Finder window, but then I would have to manually open all the folders one by one before copying/pasting. Too time consuming.

TextWrangler: The output is ok, but I feel like I would like to have more options regarding how many levels deep the exported file list is, otherwise I end up with 33k lines of text. Good but not customizable.

Terminal: Some courageous experts have shared how to do it with Terminal, but I'm not super comfortable with it, and most importantly, the Volume I tried to execute the command on didn't load ("No such file or directory") – maybe because there are spaces in my Volume names? (this tip did not work when trying to add a Volume name with spaces in a Terminal prompt to output file names…). Did not work.

At the end of the day I ended up purchasing a paid app, but since I use several different user accounts across several machines, I would love to know if there is an easier and free way that I can use in the future.

Machine: iMac Mid-2011 with High Sierra.

Best Answer

  1. Open Terminal.app from the utilities folder
  2. Inside the terminal window, type cd then a space
  3. Open the parent window of the directory you want a listing of in finder (One folder / directory up from the one you want a listing of. It should contain the directory you want a listing of)
  4. Drag the directory you want a listing of into the terminal window, then hit the enter key inside the terminal window
  5. Inside the terminal window type ls >> ~/Desktop/listing.txt (making sure that listing.txt isn't the name of a file that already exists on your desktop) then hit enter
  6. listing.txt will get created on your Desktop
  7. Optional: Open listing.txt on your Desktop and confirm the contents match the directory

This is going to produce the contents only for that folder, not it's subfolders. if you want to recursively list the entire contents use ls -R >> ~/Desktop/listing.txt instead in step 5

For a recursive listing in a different format, replace ls with find in step 5 (don't add -R to the end)