Listfiles( volumes and invisible files

I have a setup with a Text List displaying the contents of the folder. A click on the list opens a nested folder or, if it’s not a folder, displays the File Info in an adjacent area. There’s adjacent button to navigate upward a folder at a time.

The navigation is done by using listfiles( and either adding or subtracting the last item in the folder path. It all works as desired until I hit the “top”.

A typical path would be: /Volumes/IDH2/2022/March

When it gets cut down to /Volumes, the display is something like:
ThisMac
HD2
HD5
HD5 Backups

ThisMac represents the name of the computer. To get ThisMac included I had to delete the ƒ from the listfiles( parameters, so it’s apparently not seen as a folder.

Clicking on any of the listed volumes produces a list of the contents, ThisMac is an exception. Nothing shows up when it is chosen. On my Desktop the computer can be seen under Locations. Clicking on that shows the computer’s HD bearing the same name as the computer, plus all connected volumes.

I would expect that /Volumes would be the equal to Locations and that ThisMac represents the computer’s HD.

So the issue is how to properly list the top hierarchy of volumes and be able to drill down on the computer’s HD from there as I can with the other volumes.

Also, is there any parameter that can be applied in listfiles( that hides invisible files?

The listfiles( function does not appear to address hidden files but the filecatalog( function does not show hidden files by default.

Thanks Gary. Filecatalog( does have the ability to hide invisible files but instead of a list of the individual files and folders, each is listed with its entire path. That adds a lot of filtering in the several places that I’d need to apply it to some already involved path processing.

It may be my only choice aside from letting invisible files show but at the moment I’m inclined to stick with list files(.

I can see where that would be a problem for listing large numbers of files. I did a comparison using the 100+ files in my Downloads folder using:

arrayfilter(filecatalog("/Users/garyyonaites/Downloads"),cr(),{arraylast(import(),"/")})

compared to:

listfiles("/Users/garyyonaites/Downloads")

Using listfiles( was three times faster than using the arrayfilter( & filecatalog( method. So, I guess it all depends on how important it is to eliminate the hidden files.

I had the impression that filecatalog( was slower too but without evidence to back it up I was reluctant to say so. :thinking:

UNIX handles volumes in a way you might not expect. The boot volume is handled differently than externally mounted volumes. Normally only externally mounted volumes are listed under /Volumes.

It appears that Apple is doing a trick to make the boot volume appear in this list. I think maybe it is putting a symlink in the /Volumes folder to the real boot volume location, which is / (just a slash). If you do

listfiles("/")

you’ll see the files and folders on the root folder.

To get this to work, you’re going to need some special case code when you are displaying /Volumes. You can calculate the name of the boot drive with this formula:

before(hfspath("~"),":")

(There may be a better way to do this, but this seems to work.)

I think I would NOT delete the ƒ from the listfiles parameter, but instead manually add the boot drive to the list when listing /Volumes. But either way will work.

Then if the user clicks on the boot drive, you have to change the path to “/”, not “Volumes/boot drive”

As for the speed of listfiles vs filecatalog, I suspect that is just because filecatalog is returning a LOT more information.

NEWS FLASH – UNDOCUMENTED OPTION IN FILECATALOG

In researching this post, I discovered that filecatalog( has an undocumented option, shallow. If this option is true, only the current folder is listed, it doesn’t recurse to all enclosing folders. I think I just forgot to document this, in fact I completely forgot that I wrote this option.

For example, this formula will list only files and folders on my desktop, less than a dozen items.

filecatalog("~/Desktop","shallow","true")

But this formula will list every file and folder inside every folder on the desktop – hundreds or thousands of files.

filecatalog("~/Desktop","shallow","false")

I’m not sure this helps you in the case of the /Volumes folder, but I should really add this option to the documentation. In fact, ok, I just added it.