Delete old WhatsApp pictures?
Moderator: Martin
Delete old WhatsApp pictures?
I'm trying to make a flow to delete old WhatsApp pictures because I belong to a few groups, which sends them I little too much for my available memory. My goal is to check the specified folder and delete pictures older than five days.
This should be simple, but I don't quite get the grasp of it. The image names are formatted easily to achieve this: IMG-yyyyMMdd-Wxxxxx, where xxxxx is image number.
I should be able to isolate the date from the filename, format it so that Automagic understands it and the calculate, if five days has passed.
I can do the calculations and I have a slight idea of how to isolate the date but I'm totally lost in formatting it right.
Any help is appreciated.
This should be simple, but I don't quite get the grasp of it. The image names are formatted easily to achieve this: IMG-yyyyMMdd-Wxxxxx, where xxxxx is image number.
I should be able to isolate the date from the filename, format it so that Automagic understands it and the calculate, if five days has passed.
I can do the calculations and I have a slight idea of how to isolate the date but I'm totally lost in formatting it right.
Any help is appreciated.
Re: Delete old WhatsApp pictures?
At the moment the init file list action produces following list, which is my starting point:
[/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140919-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140919-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140920-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140923-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140923-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140924-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140924-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/Sent]
[/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140919-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140919-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140920-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140923-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140923-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140924-WA0000.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20140924-WA0001.jpg, /mnt/sdcard/WhatsApp/Media/WhatsApp Images/Sent]
Re: Delete old WhatsApp pictures?
Hi,
first I would calculate destination day like
delDay=addDays(triggertime, -5); //current date minus 5
searchString=("{delDay, dateformat,yyyyMMdd}") ; //string to be search in file names
Using a for loop you can search inside your path list. Each path that contains search string has to be used for file delete
Regards
first I would calculate destination day like
delDay=addDays(triggertime, -5); //current date minus 5
searchString=("{delDay, dateformat,yyyyMMdd}") ; //string to be search in file names
Using a for loop you can search inside your path list. Each path that contains search string has to be used for file delete
Regards
Re: Delete old WhatsApp pictures?
For sure, you have to compare islated dates from file names with search string (maybe converted to num) and delete everthing equal or older 5 days
Re: Delete old WhatsApp pictures?
I'm totally lost here. I couldn't get even the regexp to work. I didn't look at the list operations yet, because I have no idea, where should I even start the script.
Example of one regexp I tried to isolate the date with. I believe that the basics are right and with small modifications it should work. I tried a lot of different things, but no avail.
http://automagic4android.com/flow.php?i ... c2ab3f241f
Example of one regexp I tried to isolate the date with. I believe that the basics are right and with small modifications it should work. I tried a lot of different things, but no avail.
http://automagic4android.com/flow.php?i ... c2ab3f241f
Re: Delete old WhatsApp pictures?
http://automagic4android.com/flow.php?i ... 943417c1f7
Hi,
here you can find a flow with single script. I generate a list which could be from action init filelist and log messages that describe delete process. You can see how I extract date from filename. Match instruction is not needed in thst case.
Hi,
here you can find a flow with single script. I generate a list which could be from action init filelist and log messages that describe delete process. You can see how I extract date from filename. Match instruction is not needed in thst case.
Re: Delete old WhatsApp pictures?
Thanks for thereply but are you sure, you posted right flow?
Re: Delete old WhatsApp pictures?
//current time minus 5 days
newdate=addDays(triggertime, -5);
deldate="{newdate, dateformat, yyyyMMdd }" ;
log({deldate}) ;
//filename list which could be returned from action init filelist
filelist=newList( "IMG-20150114-W00000", "IMG-20150101-W00000" ) ;
//treat each element of filelist
for (a in filelist)
{
//extract date stamp
filedate={substring(a,4,12)};
log({filedate}) ;
//check if equal or older
if (filedate<=deldate)
{
log("{a} deleted") ;
}
else
{
log("{a} not deleted") ;
}
//
} ;
newdate=addDays(triggertime, -5);
deldate="{newdate, dateformat, yyyyMMdd }" ;
log({deldate}) ;
//filename list which could be returned from action init filelist
filelist=newList( "IMG-20150114-W00000", "IMG-20150101-W00000" ) ;
//treat each element of filelist
for (a in filelist)
{
//extract date stamp
filedate={substring(a,4,12)};
log({filedate}) ;
//check if equal or older
if (filedate<=deldate)
{
log("{a} deleted") ;
}
else
{
log("{a} not deleted") ;
}
//
} ;
Re: Delete old WhatsApp pictures?
Ähm.....yes.the link is correct. Its pointed to related flow named FlowScript
I posted script in last post
I posted script in last post
Re: Delete old WhatsApp pictures?
Because you didn't change the name for the action, AM showed me the original instead of your updated scrip. I had to rename the original script first. Seems like here's a place for a bug report.andy wrote:the link is correct.
How does the substring work? "a" is the variable's name for the file, 4 is where substring starts and 12 where it ends, correct?
Then should I check with expression if the "deldate"is more than 5 days and if true, delete "a" file?