Ubuntu – print contents of a directory structure (filesystem) to CSV on the command line

command linecsvfilesystemlstext;

How can I catalog the contents of a filesystem to a CSV file? This is particularly useful for removable media.

I've found a couple links that point in this direction:

Thank you!

Best Answer

This creates a CSV file listing.csv with file name, time stamp and size for all files in /some/folder/ and its subfolders:

find /some/folder -printf '"%P";"%Tc";"%s";\n' > listing.csv

See the documentation for -printf in the manpage for find if you want to use other fields.

Note that it doesn't work for file names containing " characters.