Unable to delete files Samsung Android 12/13

Solved
LC
Leon Callsen
Taneri Consulting GmbH (TCG Global)

Hi Everyone, 

I have another question for you guys because I am unable to find a solution for my issue. 
For an app we're installing on Samsung Tab Active 3 with Android 12/13. 
We have to store additional files in the path: "/sdcard/Documents/App"
Due to Scoped Storage we have to use a folder like this. 

We want to rollout a new version of this app and have the change the every file in this path mentioned above. 
If I update my profile where these additional files are stored than the old files won't be deleted. 

I tried to add a preinstall-script like "del /sdcard/Documents/App" to delete the old files. 
It doesn't work. The only options for me which is working is to deleted the files on every device manually over remote control. 
If I remove or revoke the profile nothing happens on the device. 

Do you have any ideas how I can delete those files because I got more than 700 devices. 

2 years ago
Android
ANSWERS
RC
Raymond Chan Diamond Contributor
2 years ago

Mobicontrol legacy script command "del" does not support recursive deletion down a sub-directory tree. 

If you have subdirectories under %sdcard%/Documents/App, you can try using the legacy script command

    rmdir /S    %sdcard%/Documents/App

to remove the whole subtree.

I have just tested the command to be working on many Samsung devices running Android 12/13, and there should be no need to use file-sync rule with deleting source file option. I can't imagine how chaotic your bulk upgrade process will be if you deploy the file-sync rule to all your 700 devices at the same time when different devices have different on-line/off-line status and old/updated app versions running/installed.

Solution
RS
Rafael Schäfer
2 years ago

Hi Leon,

try follwoing script:

del "%sdcard%/Documents/App/*.*"
 
 
LC
Leon Callsen
2 years ago

Hi Rafael, 

unfortunately that doesn't work. 
I just copied your script.


7
74HCT04
2 years ago

With our Honeywell CT60 devices running Android 11, I found that the uninstall script command was ignored with the kiosk switched on (Native lockdown). I wrote a script to disable the kiosk (lockdown) whilst uninstalling and deleting files to workaround this and made it into a package.

Here's a script to try if your devices are locked down. The 5 second delay is probably superfluous :

notify kiosk off

del /sdcard/Documents/App/*.*

sleep 5

notify kiosk on

LC
Leon Callsen
2 years ago

Hi 74HCT04, 

I disabled the lockdown before. 
Unfortunately nothing happens on the device. 

Maybe because the app which is using the files is running? 

ZC
Zafer Cigdem
2 years ago

Hi Leon,

You can use the scripts mentioned above, and you can put it onto a Profile --> Task Scheduler to run it periodically. Or alternatively, you can get this files from devices to server via File Sync rule and select "delete source files after sync" option to delete them from devices as below.

I hope it helps. Thank you

Zafer

LC
Leon Callsen
2 years ago

Hi Zafer, 

this option would increase the traffic on the server massively right? 
So like 700 devices would upload their files. 
This would be around 1.4 TB of files. 

7
74HCT04
2 years ago

Try the script:


kill_application <bundle id>

before deleting the file. For example, to kill the Google calculator:

kill_application com.google.android.calculator


you can find the bundle activity in the device logs as the part before the "/" returned by the following script when the app is running in the foreground (open on screen):

Identify_activity

LC
Leon Callsen
2 years ago

With Zafers Method I was able to get the files from the device. 
But the Folder and Subfolder still exists. 
I have to delete them aswell I guess. 

ZC
Zafer Cigdem
2 years ago

Hi Leon,

For this kind of big total amount of files, I don't advice file sync option for sure. I don't remember well, but for one case delete script did not work for me, and I prefer using the file sync option for only 1 time delete files from device (not a periodic deletion such as every X amount of time) for small amount of files, so that's why I mention this as an alternative option. I also advice to use script first to not consume bandwidth. But still to answer your question, AFAIK, if you do something below on your FileSync rule by enable "Sync Sub-Folders" as "yes" on File Sync rule advanced section, that should delete any file under the target folder and it's sub folders. Please see an  example that I just did on my test Samsung device below. The target folder that I want to delete %sdcard%/Download/folder_to_delete_from_device

After deletion, there is only folder names apprears, all related files under the target folder were deleted, as below:

I hope it helps. Thank you

Zafer

RC
Raymond Chan Diamond Contributor
2 years ago

Hi Leon,

As you mentioned about 1.4TB of data traffic for 700 devices for using file-sync rule, your additional files in your "app" subdirectory tree should include multiple files with total size of around 200MB on top of the app they support.

This is a typical case in which the app and supporting files should be deployed with a .pcg package that includes properly tested pre-/post-install/uninstall scripts.  If required, the script can include operations such as gracefully/forcefully killing running apps, turning on/off the kiosk, deleting/renaming/moving support file(s), etc. Compared to file-sync rule, there are more advanced options such as checking available free memory, firware version, etc. before the installation, and whether to uninstall/remove the app when the policy is revoked.

The file-sync rule does not natively support such options, and includes extra data overheads for comparing large number of files in both the source and destination directory trees. 

To conserve data traffic/bandwidth, test on validity of the script(s) used should be done with test device before large-scale deployment on all 700 production devices, whether you are using file-sync rule or .pcg package for the deployment. Also, if only a small number of support files need to be added/deleted/changed between two app versions, the upgrade .pcg package can be made smaller by just including the new/changed support files, and script to delete unnecessary/old files.

Finally, using device-to-server file-sync rule purely for the sake of removing a hierarchy of file in the device directory does not make any sense to me due to the wasted network bandwidth, server cpu/storage and time to complete the task, especially in cases with  larger number of devices or big chunk of files.  If I encounter similar problem , I would rather spend time carefully testing the "delete" related script command(s) for any typo, directory macro validity and/or read/write permission, new/obsolete command options, etc.  

LC
Leon Callsen
2 years ago

Hi Raymond, 

Thanks for both of your answers. 
The Script you provided me was the same I received from SOTI Support some hours ago. 
I was not aware of the difference use cases where I have to use which script. 

The Topic is solved for me. 
I included the script into my .pcg file which contains the additional app files. 

Thank you very much! 

M
MNMOD@SOTI
2 years ago

Hi Leon,

Thank you for posting on SOTI Pulse!

Thank you for marking Raymond's post as solution. If you require any more assistance, please feel free to let us know.

Kind regards,

Technical Support Specialist | SOTI | +1 905.624.9828 | SOTI.net l Discussion Forum | Log a Case Online l Facebook l LinkedIn l Twitter