Fileinfo( function returns incorrect results

Each of these commands

message fileinfo("PanX conversion tester.pandb")
message fileinfo(dbfolder()+"SecondTest.pandb")

returns the filetype as “Folder” and the file size as zero. Omitting the extension gives an empty result.

Interestingly, if I run fileinfo( on a .pandb file in Pan 6, I get a similar result, with the filetype returned as “Folder” and the file size as 7 bytes.


… and fileinfo( of a Pan6 database correctly records it as a “File” but it returns an empty type code.

Sorry - brain fade. This was covered recently because a PanX database is a folder/package. Still, the incorrect size warrants investigation - fileinfo( returns a zero size for all folders.

That is the correct value – folders have zero size.

Perhaps you were expecting that it would return the cumulative size of all items inside the folder, but it doesn’t work that way. There is no reasonable way for a program to find this out. Notice that in the Finder, the size of all folders is listed as --.

… unless I choose the Calculate all sizes option in View>Show View Options. My recollection is that not showing folder sizes was the default because to do otherwise was too much of a demand on resources - perhaps when CPUs were the equivalent of a 40 watt bulb?


Not on my system. :slight_smile:

The Finder by default does not display the size of a Folder for reasons of efficiency but by using the View/Show View Options and checking ‘Calculate all sizes’, your folders will display the cumulative sizes of the files within it.

Robert Ameeti
(949) 422-6866

Just a note to say that I just entered an issue #540 in Bitbucket regarding the foldersize statement returning seemingly inaccurate values. My experiments showed much lower values returned for the folder size when compared to results in the Finder or using du -sh in the Terminal or via shellscript. In case you want to test this as well, here is the code I used to compare foldersize with the unix command’s results:

local theFolder, FolderSizedu,FolderSizefs
ChooseFileDialog theFolder,"folders",true()
FolderSizedu=pattern(val(array(shellscript({du -shk }+unixshellstring(theFolder)),1,tab())+"000"),"#,")
message "du -shk = "+FolderSizedu+¶+"foldersize = "+FolderSizefs

The results in the Finder are always very close to the du returns.