1. Home
  2. Knowledge Base
  3. SureMDM
  4. General questions
  5. How to retrieve the number of files in a folder using a custom property
  1. Home
  2. Knowledge Base
  3. SureMDM
  4. How to retrieve the number of files in a folder using a custom property

How to retrieve the number of files in a folder using a custom property

Purpose

This article explains how to retrieve the count of files within a specified folder using a script and display the count as a custom property in the SureMDM console. Using this approach allows administrators to monitor file counts remotely without requiring manual access to the device.

Prerequisites

  • Administrator access to the SureMDM Console
  • The target device must be enrolled in SureMDM and actively online
  • The target folder path must exist on the device.
  • Device must be online and connected periodically to sync the custom property

Steps

  1. Log in to the SureMDM console
  2. Create a custom device property in account settings with the below script
function assignValue(){
var result= suremdmjs.listFiles("/sdcard/Documents");
var list = JSON.parse(result); // here list will be JSON Array
return list.length.toString();
}


  1. Assign the created property to a subgroup
  2. Once the device property is synced
  3. Verify the value in the device properties of the devices present in the group

Conclusion

By configuring a custom property with the appropriate script, administrators can efficiently retrieve and monitor the number of files within a specified folder directly from the SureMDM console. This method eliminates the need for manual device access, improves visibility across managed devices, and enables quicker decision-making based on real-time file data.

Need more help? Here’s how to get help from our experts. 

CONTACT US

Was this helpful?
YesNo
Updated on March 2026
Need Support?
Can't find the answer you're looking for?
Contact Support