2

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!

2 Answers2

4

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.

rubo77
  • 32,486
  • Florian, I'm getting a > prompt when I run this command and I have to Ctrl+c to get out of it. What am I doing wrong? – Sean Fenton Aug 23 '13 at 11:25
1

If you need this to access the files on your external harddrive a better solution would be to create an index with extra options on updatedb

add this to your ~/.bashrc:

alias updatedb-external='sudo updatedb -l 0 -o ~/.externalharddisk.db -U /media/path/to/harddrive/'
alias locate-external='locate -d ~/.externalharddisk.db:'

then you can query that list with that alias:

locate-external some-file

update your list with

updatedb-external
rubo77
  • 32,486