How to list all files in directory excluding any that start with a dot?

Solution 1:

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

Solution 2:

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

Solution 3:

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