Page 1 of 1
files less than 512 k.b
Posted: 09 Mar 2019 06:12
by Rafi4
hi all
is there any way to delete automatically files which are less than 512 k.b?
example
trigger = time 1.00 p.m
action = init Variable File List
expression =files less than 512 k.b
true = delete file
from record4
Re: files less than 512 k.b
Posted: 09 Mar 2019 06:52
by anuraag
Enable "Include file attributes" in init Variable file list. Then use following expression. del_list will contain files lists below 512kb
Code: Select all
del_list=newList();
for (file in files)
{
if (!isDirectory(file[0]) && file[2]<512*1024)
{
addElement(del_list, file[0])
}
}
if (length(del_list)>0)
{
return true
}
else
{
return false
}
Re: files less than 512 k.b
Posted: 09 Mar 2019 08:10
by Rafi4
hi
not working. error absolute path after selecting current path.
Re: files less than 512 k.b
Posted: 09 Mar 2019 08:14
by anuraag
I have tested it. Try this flow
Re: files less than 512 k.b
Posted: 09 Mar 2019 12:46
by Rafi4
hi anuraag
not working in my device. my device is Samsung Galaxy j2.
from record4
Re: files less than 512 k.b
Posted: 09 Mar 2019 13:29
by anuraag
Share log
Re: files less than 512 k.b
Posted: 09 Mar 2019 13:38
by Rafi4
hi
Re: files less than 512 k.b
Posted: 09 Mar 2019 13:51
by anuraag
Code: Select all
09.03.2019 19:04:58.449 [Files less than 512kb] Start executing action 'Init Variable File List: files to /storage/emulated/0/Download'
here is error
Try this flow by deleting previous one.
Re: files less than 512 k.b
Posted: 11 Mar 2019 14:41
by Desmanto
@anuraag : The last line of the expression can be any statement that evaluate to true or false. So you can optimize the last checking a bit. Instead
Code: Select all
if (length(del_list)>0)
{
return true
}
else
{
return false
}
I would use only
Both result the same. But of course the former is more readable.