App to export file lists

I would like to export information from a folder to a spreadsheet and include the folder names and sizes. It is possible to make a list of files or folders in Excel (by simply copying and pasting the files/folders into a spreadsheet) but I can’t find a way to include folder sizes as well.

A bit of research yielded the app File List Export which seems to fit the bill well. However, I was wondering if there is a less elegant/free alternative to it that would get the job done. Thanks!

You could,do this with Terminal (bash) commands, if you’re open to that. There is a near-infinite number of ways to gather and format the text.

Open Terminal

cd ~/Documents/yourfolder
stat -f "%N,%z" | pbcopy

cd changes directory to the folder you’re interested in. ~ is your home folder. In Finder, this would be the house icon with your user name. Then moves into the Documents folder and yourfolder

stat -f "%N,%z" prints the file name (%N), then a comma, then the file size (%z).

The vertical bar (also called pipe) sends the output of the stat command to the pasteboard copy command pbcopy.

Now, switch over to Excel (I assume) and Cmd+V to paste.
If you’re lucky, you’ll get two columns, filenames, and sizes. If it pastes in as one column, use Text to Columns... in the Data menu to convert it to separate columns. Choose the comma as the separator. I just did that on my sample data, and Excel remembered it so I didn’t have to do it again for this spreadsheet.

Here’s a sample of what the command produced on my system.

1098-T 2017.pdf,223770
Bookends CheatSheet.pdf,51294
EEG Processing Pipeline.pdf,34134
Jean-Léon Gérôme and Polychrome Sculpture.pdf,371825
Kolbe A Result for John Johnson.pdf,1376239
Misinterpretation of one of Issac Newtons writings.pdf,412847
Vision Statement.pdf,14455

For this example, I limited it to only .pdf files in my Documents folder by using this command: stat -f "%N,%z" *.pdf | pbcopy

And in the spreadsheet:


I use File List Export. Great application for what you’re trying to do.

1 Like

Just bringing this old thread to life again. I need to do a file list export into a spreadsheet and wonder if this was still the best way to achieve it (i.e. using Terminal). Any thoughts apprieciated.

If you just need the file names, you can select them in Finder, switch to Excel, and Cmd-V to paste, and you’ll get a list of filenames.

Thanks @JohnAtl . I do need a bit more than that as I have a top level folder with various sub level folders and files. I need a list of each, ideally with file names and size.

There might be another way besides using the Terminal, but this will get you a list of all files and their sizes. The output will be in the file file_list.csv that you can open in your spreadsheet program.

find . -exec stat -f "\"%N\",%z" {} \; >file_list.csv

The contents look like this:


I don’t know what you know, so:
From Finder, open Applications, then Utilities, then double-click Terminal
You’ll be in your home folder (e.g. /Users/timlawson) ready to type a command.
Type cd Documents/Projects/Whereever to change to the folder that you want the listing of.
Copy the find… command above, then paste it in the Terminal window, then press Enter.
Things will work for a few seconds, then your file_list.csv file will be ready.

Let me know if that works, or not.

1 Like

Many thanks @JohnAtl that works perfectly. It has done exactly what I needed.
I will now keep your code for the future!

1 Like