How mighty is the Script-Action?

Post your questions and help other users.

Moderator: Martin

Post Reply
dabigfish
Posts: 4
Joined: 25 Oct 2017 12:39

How mighty is the Script-Action?

Post by dabigfish » 01 Nov 2017 11:28

Sorry my english is just bad, so in german.

I'm wondering if you can execute block triggers / block conditions / block actions in the script as well and process their results?

My long-term goal is a program in the background, that with too little internal / external memory by itself begins to delete the oldest files, so that afterwards a previously defined value of free memory is reached / is available. User-defined folders / subfolders should be analyzed in terms of their total size in bytes / number of files. The deletion of the oldest files in each folder should be weighted. So folders that contain large amounts of data, should be taken into account when deleting more than folders with less data.

At the same time, it should always be checked whether certain conditions are met on the mobile phone. If not, the analysis / deletion should be aborted and the program should go to sleep again until the conditions for awakening are fulfilled.

Is it really possible to do this with Automagic?

Thanks & greetings, BIG


Sorry mein Englisch ist nur schlecht, deswegen auf deutsch.

Ich frage mich, ob man im Skript auch Block-Trigger / Block-Bedingungen / Block-Aktionen ausführen und deren Ergebnisse weiterverarbeiten kann?

Mein Fernziel ist ein Programm im Hintergrund, dass bei zu wenig internem / externem Speicher von alleine beginnt die ältesten Dateien zu löschen, so dass danach wieder ein vorher definierter Wert an freiem Speicher erreicht wird / zur Verfügung steht. Dabei sollen vom Benutzer definierte Ordner / Subordner hinsichtlich ihrer Gesamtgröße in Bytes / Anzahl Dateien analysiert werden. Die Löschung der ältesten Dateien in den einzelnen Ordner soll gewichtet erfolgen. Also Ordner die große Datenmengen beinhalten, sollen beim Löschen stärker berücksichtigt werden als Ordner mit weniger Datenmengen.

Gleichzeit soll immer geprüft werden, ob am Handy bestimmte Bedingungen erfüllt sind. Falls nicht, soll die Analyse / das Löschen abgebrochen werden und sich das Programm wieder schlafen legen, bis die Bedingungen zum erneuten Erwachen erfüllt sind.

Lässt sich so etwas wirklich mit Automagic realisieren?

Danke & Gruß, BIG

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: How mighty is the Script-Action?

Post by Martin » 01 Nov 2017 20:46

Hi,

Action Script does not allow to execute arbitrary conditions and actions (except maybe by using the java features). I also don't recommend to do this since it would cause the flow to be executing permanently which would consume quite a bit of battery.
I would create a regular flow with conditions, actions and a loop to delete files when trigger Device Storage Space Low is executed or you could also execute the same flow periodically (e.g. once an hour) and use a condition Device Storage Space first to see if free space is below a certain level.

Regards,
Martin

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How mighty is the Script-Action?

Post by Desmanto » 02 Nov 2017 12:17

This will depends a lot on what kind of data you have, what is the size, date span range, typical usage, how folder structure inside and so many other things to be taken into account. A very specific usage for your own purpose.

The easiest way, of course to check only based on date. Such as in CCTV/IP cam video recording. The folder with the oldest name date will be deleted when running out of storage.

If you need to weight the size also, you need to create your own scheme of weighting/metric. You have to determine how many days is considered "old", and how many KB/MB/GB is considered "big". Then assign a weighting value based on the file modified date and size. The higher the value, the more it prioritized to be deleted.

I never have a concept on this before, so this is just example. Let's say you want the data from the last 3 months only, anything above that can be deleted safely. While 1 GB file will be considered big, and will be deleted first if low space.
Date (unit day)
0-100 = add the days as the metric
>101 = Add the day + 1000

Size (unit MB)
0-1000 MB = add the MB as the metric
>1001 MB = add the MB + 1000

So if there is file A which is 45 days old with size 100 MB and. It will be 45 + 100 = 145. File B 1 days but with size 750 MB, will be 1 + 750 = 751. The 750 Mb will get deleted, since 751 is much higher than 145. But if file C is 120 days old, with only 10 MB size; it will be 1120 + 10 = 1130. It will be deleted faster, since it is more than 3 months already. If you don't impose time limit, small files will never get deleted because there are files with higher file size which will skew the metric. This scheme will be very dependant on your specific usage.

To query the file size, you can use "Init Variable File List". But maybe it is easier to use command line, du command to do in bulk.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

dabigfish
Posts: 4
Joined: 25 Oct 2017 12:39

Re: How mighty is the Script-Action?

Post by dabigfish » 03 Nov 2017 09:39

Hi Guys, thanks for your replies. I will keep your suggestions in mind. But maybe i will realize it with android studio. Regards, BIG

Post Reply