Delete old WhatsApp pictures?

Post your questions and help other users.

Moderator: Martin

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Delete old WhatsApp pictures?

Post by andy » 15 Jan 2015 20:48

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"

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Delete old WhatsApp pictures?

Post by andy » 15 Jan 2015 20:56

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.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Delete old WhatsApp pictures?

Post by MURTUMA » 28 Jan 2015 16:37

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.

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Delete old WhatsApp pictures?

Post by andy » 28 Jan 2015 17:17

Did you try it using reverse() intruction?

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Delete old WhatsApp pictures?

Post by MURTUMA » 28 Jan 2015 18:59

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)

andy
Posts: 40
Joined: 29 Dec 2014 21:00

Re: Delete old WhatsApp pictures?

Post by andy » 28 Jan 2015 19:30

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

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Delete old WhatsApp pictures?

Post by MURTUMA » 01 Feb 2015 19:18

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

Post Reply