files less than 512 k.b

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

files less than 512 k.b

Post by Rafi4 » 09 Mar 2019 06:12

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
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: files less than 512 k.b

Post by anuraag » 09 Mar 2019 06:52

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
}
Last edited by anuraag on 09 Mar 2019 08:23, edited 1 time in total.

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: files less than 512 k.b

Post by Rafi4 » 09 Mar 2019 08:10

hi
not working. error absolute path after selecting current path.
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: files less than 512 k.b

Post by anuraag » 09 Mar 2019 08:14

I have tested it. Try this flow
Last edited by anuraag on 09 Mar 2019 13:54, edited 1 time in total.

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: files less than 512 k.b

Post by Rafi4 » 09 Mar 2019 12:46

hi anuraag
not working in my device. my device is Samsung Galaxy j2.
from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: files less than 512 k.b

Post by anuraag » 09 Mar 2019 13:29

Share log

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: files less than 512 k.b

Post by Rafi4 » 09 Mar 2019 13:38

hi
Attachments
log.txt
(2.88 KiB) Downloaded 577 times
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: files less than 512 k.b

Post by anuraag » 09 Mar 2019 13:51

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.
Attachments
flow_Files_less_than_512kb_20190309_191930.xml
(2.14 KiB) Downloaded 656 times

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

Re: files less than 512 k.b

Post by Desmanto » 11 Mar 2019 14:41

@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

Code: Select all

length(del_list)>0
Both result the same. But of course the former is more readable.
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.

Post Reply