Zebra TC52 Devices – Photo Storage Cleanup via SOTI

Solved
I
IK
IK

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.)?

3 months ago
SOTI MobiControl
ANSWERS
RS
Robert Schäfer
3 months 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!

I
IK
3 months 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
3 months 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
I
IK
3 months ago

Thanks, Matt. That solved my problem.

EG
Edgar Gomez Platinum Contributor
3 months 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(); } });
I
IK
3 months ago

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