substring extract from given string the part between start and end index based on 0 (first character gets index 0).
X=substring("abcde", 2,3)
-->X="cd"
Delete old WhatsApp pictures?
Moderator: Martin
Re: Delete old WhatsApp pictures?
http://automagic4android.com/flow.php?i ... 0498f8cd24
Attachted flow you can try out.
1. It writes file list in list variable
2. In script I access to this list and write all files that matches date filter in a new list
Iteration is different to last version. I access to list element using index.
3. New list I use for delete files action
4. Exeption is needed to avoid runtime error if new list is empty
Advantage of this solution is I dont need to generate a loop outside script. Action Delete files can handle comma separated list. So its better to create a filtered list which one I give to Delete files action.
Attachted flow you can try out.
1. It writes file list in list variable
2. In script I access to this list and write all files that matches date filter in a new list
Iteration is different to last version. I access to list element using index.
3. New list I use for delete files action
4. Exeption is needed to avoid runtime error if new list is empty
Advantage of this solution is I dont need to generate a loop outside script. Action Delete files can handle comma separated list. So its better to create a filtered list which one I give to Delete files action.
Re: Delete old WhatsApp pictures?
Finally I had a chance to look into this.
Your script works great! Thank you for your help! However, I tried to make a little addition to it but never got it working. I'm trying to modify the removeFiles list so, that it leaves at least five pictures.
1. Reverse removeFiles list order as it seems to be ordered by date ascendly.
2. Compare the initial files list and removeFiles list.
3. If the list length difference is equal or less than five, do the math and remove correct amount of elements from the beginning of removeFiles list. (This is why to reverse list order so it retains newer pics and indexes are easier to calculate from the beginning as the list length may vary.)
Simple logic, but I've been unable to get even the first step working. Automagic only complains that the "thing" I'm trying to reverse is not a list. I've been using the examples from the script help.
Your script works great! Thank you for your help! However, I tried to make a little addition to it but never got it working. I'm trying to modify the removeFiles list so, that it leaves at least five pictures.
1. Reverse removeFiles list order as it seems to be ordered by date ascendly.
2. Compare the initial files list and removeFiles list.
3. If the list length difference is equal or less than five, do the math and remove correct amount of elements from the beginning of removeFiles list. (This is why to reverse list order so it retains newer pics and indexes are easier to calculate from the beginning as the list length may vary.)
Simple logic, but I've been unable to get even the first step working. Automagic only complains that the "thing" I'm trying to reverse is not a list. I've been using the examples from the script help.
Re: Delete old WhatsApp pictures?
Did you try it using reverse() intruction?
Re: Delete old WhatsApp pictures?
Yes. At first I tried to create a new list from removeFiles and that might have caused the error. However, when I tried to directly reverse removeFiles list, nothing happens.
reverse(removeFiles)
reverse(removeFiles)
Re: Delete old WhatsApp pictures?
X=newList("c", "b", "a") ;
log({X}) ;
reverse(X);
log({X}) ;
I had never used this instruction. Now I did a test. For me it works. Reverse() changes order to a, b, c
log({X}) ;
reverse(X);
log({X}) ;
I had never used this instruction. Now I did a test. For me it works. Reverse() changes order to a, b, c
Re: Delete old WhatsApp pictures?
For some reason i can't get it to work. I've tried it with and without sorting instruction, but no luck. I see no problem in the script, so I wonder, where the error is.
http://automagic4android.com/flow.php?i ... 5a7ce7000a
http://automagic4android.com/flow.php?i ... 5a7ce7000a