How to Get Folder Size and Contains Information in LabVIEW?

Updated Apr 9, 2024

Environment

Software

  • LabVIEW

Inside Windows explorer, when you right click on a folder and go to properties, it shows the folder's general information. This document will explain how to get folder's size and contains information programmatically in LabVIEW.

folder size wd.PNG

Use System Exec function with cmd/c dir /s "directoryPath" (where directoryPath is the path to your folder), then parse the size back out of the result.The same approach can be done on Linux or with Powershell.

To parse out folder information from System Exec function's standard output terminal, use the Match Pattern Function.
※Note that System Exec function output string will display result in your windows display language, so adjust the Match Pattern function's regular expressions (1), (2)  and (3) to your system display language.

folder size setting.PNG

Folder size will display in bytes but you can use Scale by Power of 2 function to convert the size into your desired unit.
size scale.PNG

Below is the program settings to parse folder's size and contains out of System Exec's standard output terminal (sample program can be downloaded from the attachment files at the bottom of this article).

folder size pgm.PNG

folder size rsl.PNG

Attachments