Zebra TC52 Devices – Photo Storage Cleanup via SOTI

Solved
IK
ismail kurnaz
mobisis2025

Our customer is using Zebra TC52 devices. Users take photos to document issues, but over time these photos accumulate and cause storage problems. Is it possible to automatically or remotely clean up this photo gallery through SOTI? If so, what methods would you recommend (e.g., script, SOTI policy, app-level solution, etc.)?

a month ago
SOTI MobiControl
ANSWERS
RS
Robert Schäfer
a month ago

Hi Ismail,

It depends on whether your looking to simply delete, or also backup the data. To delete:

  1. Use a file sync rule with a blank folder selection to download from server to device, ensure you have "delete unmatched files and folders", that will delete the contents of the folder you target on the device. You can then schedule the file sync to run as you see fit.
  2. Use Javascript. You can loop through each file and folder in a folder on the device and based on other criteria you determine delete the files/folders.

If you do want to save the data, file sync is also the answer as you can set it to download the contents to the server and then delete the contents on the device.

Hope that helps!

IK
ismail kurnaz
a month ago

Hello Robert, thank you for your valuable support. Deleting the gallery is sufficient. No backup is needed. I'll look into how to do it with Java.

MD
Matt Dermody Diamond Contributor
a month ago

If all the images are in a single folder you can do this with wildcard and legacy scripting as well. 

This script for example will delete all *.png files in a given folder. 

del /sdcard/<folder>/*.png

You could use that concept within a Task Scheduler script set up to run every nightly.

Photo gallery can be tricky though as there can be multiple subfolders. If that is the case you may have to recursively iterate through the subfolders to clear things out as Robert has suggested with javascript.

Solution
IK
ismail kurnaz
a month ago

Thanks, Matt. That solved my problem.

EG
Edgar Gomez
a month ago
You can also delete files based on their creation or modification date. 
In this example, files older than 5 days are deleted.
#!/usr/bin/env js 
var dirPath = 'sdcard/Download';
var dir = new mobicontrol.io.File(dirPath);
var today = new Date();
var oldestDate = new Date(today.setDate(today.getDate() - 5));
dir.listFiles().forEach(file => { if (file.lastModified < oldestDate) { file.delete(); } });
IK
ismail kurnaz
a month ago

Thank you for your response. del /sdcard/<folder>/*.png solved the problem.