Is it possible to get folder size by logparser?

358 Views Asked by At

I tried the following command but it only gives size when files are encountered, it dosent provide folder size:

LogParser "SELECT Path, sum(Size) FROM D:\my_vault\*.*  GROUP BY Path" -i:FS -o:NAT -rtp:-1 -e:1 -recurse:0    

The folder structure is like : On D:\ Drive there is a folder by name "my_vault" the folder contains 8 different folders inside like folder01, folder02, folder03....folder08.

I am interested to get the folder size of my_vault and individual folders inside my_vault i.e folder01, folder02, folder03..

1

There are 1 best solutions below

2
On BEST ANSWER

You can use the EXTRACT_PREFIX function as follows:

SELECT EXTRACT_PREFIX(Path, 1, '\\') AS Folder, SUM(Size) FROM D:\my_vault\*.*  GROUP BY Folder

This will group by all files by the first two levels (e.g. D:\MyVault).

Make sure you also specify -recurse -1!