How Can We Help?
< All Topics

How do I obtain the size of a file or folder?

File Size

Use the Variable Set Integer command and select the Set Value from the Size of a File option. Select the file and the file size listed in bytes will be saved to the Integer variable selected.

Folder Size

Essentially use the Repeat with Folder command to cycle through each file in the folder. Use the above described method to obtain the file size and add the values of each file together to get the folder size. Below is an example of one way to do this.

The first line prompts to select the folder. Or you can skip this step and hard code the folder in the Repeat with Folder command.

Example for Macro Express 3:

Variable Set String %T1% from Folder Name
Variable Set Integer %N1% to 0
Repeat with Folder
  Variable Set Integer %N2% from the size of file “%T2%”
  Variable Modify Integer: %N1% = %N1% + %N2%
Repeat End
Text Box Display: Folder Size

Example for Macro Express 5 and Macro Express Pro:

Variable Set String %T[1]%: Prompt for a foldername
Variable Set Integer %N[1]% to 0
Repeat with Folder %T[1]%
  Variable Set Integer %N[2]% to the size of %T[2]%
  Variable Modify Integer: %N[1]% = %N[1]% + %N[2]%
End Repeat
Text Box Display: Folder Size

– Applies to: Macro Express and Macro Express Pro