5

I'm currently using the command

find /Volumes/DriveName > driveName.txt

to create a file listing of all files that are on the drive.

How could I modify my command (or what would be a better command) to have the list not include any dot files, for example ._Filename or .DSstore?

I'm not looking for software like CDFinder etcetera to keep a searchable database. I need a text output that contains all the files on the disk, as well as their relative locations to each other.

4 Answers 4

11

To exclude files and directories add an exclusion pattern to the find command (see info find for more):

find /Volumes/DriveName -not -path '*/.*' > driveName.txt
5
  • You could also just use ls -R /Volumes/DriveName > driveName.txt depending on the output format you want.
    – Chris Page
    Jul 13, 2012 at 22:49
  • For some reason using the -not -name is still returning results like:/Volumes/GLYPH_500//.fseventsd/000000000093d655 /Volumes/GLYPH_500//.fseventsd/fseventsd-uuid /Volumes/GLYPH_500//.Spotlight-V100/Store-V1 Jul 15, 2012 at 15:13
  • Also, ls -l is returning results like: /Volumes/GLYPH_500//.Spotlight-V100/Store-V1/Stores/550F2517-530C-4ECB-98BA-63799078A359: 0.indexArrays 0.indexCompactDirectory Jul 15, 2012 at 15:15
  • 1
    This is because -name only checks the filename, to match against the whole path replace -name with -path and the pattern with '*/.*'.
    – Thor
    Jul 15, 2012 at 15:37
  • You are right! That totally fixed it. Could you edit your response to include that - and I'll mark it as the answer. Thanks very much for your help! Jul 15, 2012 at 17:53
3

This isn't remotely Mac-specific, but you can pipe your output through grep. More particularly, the -v option will exclude lines that match the pattern you are looking for (in your case, filenames beginning with a .).

So instead of

find /Volumes/DriveName > driveName.txt

you can enter

find /Volumes/DriveName | grep -v '\/\.' > driveName.txt
1
  • this one gets rid of all items .Spotlight listings etc. Thanks. Jul 15, 2012 at 15:19
2

I was going to recommend tree as an alternative, but I realized it's not installed by default on OS X. However if you don't mind following some straightforward instructions to compile it yourself, it might be a useful tool for your purposes. It takes any directory and gives you a nice ASCII based tree of all the subfolders and files therein (and by default it omits hidden/dot files).

Sample output:

~$ tree test
test
├── alpha
│   ├── testA
│   ├── testB
│   └── testC
├── num
│   ├── test1
│   ├── test2
│   └── test3
├── test X
├── test Y
└── test Z
0

You can use ListAllFiles from the App Store.

1
  • 1
    Well, giving that you are promoting your own product here, I would have expected a bit more text and not just a link.
    – nohillside
    Aug 9, 2012 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .