• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[Tasker] Folder size/date monitoring/watching

ldm1417

Member
Hi All,

Is there a way with Tasker to monitor a folder and then:
1) delete a file, which is older than XXX.XXX (DATA.TIME)
2) delete the oldest files once the folder size is bigger than XXX (MB)

Can Tasker monitor the folders this way?

Thank you!
 
Here is a small update...
I'm trying to use the Test File' action in the task...

Here is as the command looks like:
1.jpg

Here is the command's output:
--------------------------------------------------------------------------------------------------------------------------------------------
22.30.58/E Test File: %mod -> %mod
22.30.58/FileUtil nrda: need request: /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf: false
22.30.58/E checkSDPath: /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf useRoot: true there: true file: true dir: true
22.30.58/E Test File: checkSDPath: /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf useDocFile: false
22.30.58/Shell runSync test -e '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf' root: true timeout: 3000
22.30.58/Shell have process
22.30.58/Shell write cmd: test -e '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process timeout timer 3000ms for: test -e '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process-thread ID 5417
22.30.58/Shell joined with 5417
22.30.58/Shell exit result: 0
22.30.58/Shell non-null timeout
22.30.58/Shell runSync test -f '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf' root: true timeout: 3000
22.30.58/Shell have process
22.30.58/Shell write cmd: test -f '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process timeout timer 3000ms for: test -f '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process-thread ID 5419
22.30.58/Shell joined with 5419
22.30.58/Shell exit result: 0
22.30.58/Shell non-null timeout
22.30.58/Shell runSync test -d '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf' root: true timeout: 3000
22.30.58/Shell have process
22.30.58/Shell write cmd: test -d '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process timeout timer 3000ms for: test -d '/storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf'
22.30.58/Shell start process-thread ID 5421
22.30.58/Shell joined with 5421
22.30.58/Shell exit result: 0
22.30.58/Shell non-null timeout
22.30.58/E Test File: checkSDPath: /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf ok true
22.30.58/Shell runSync ls -ld /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf root: true timeout: 3000
22.30.58/Shell have process
22.30.58/Shell write cmd: ls -ld /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf
22.30.58/Shell start process timeout timer 3000ms for: ls -ld /storage/emulated/0/Download/Adobe Acrobat/reprt533k.pdf
22.30.58/Shell start process-thread ID 5423
22.30.58/Shell joined with 5423
22.30.58/Shell exit result: 0
22.30.58/Shell non-null timeout
22.30.58/Test Test File: test mtime: 0 response code but no entry
22.30.58/E result: stop task (error)
22.30.58/Variables doreplresult: |%mod| -> |%mod|
22.30.58/E Error: 1
22.30.58/MacroEdit action finished exeID 1 action no 0 code 342 status: Err next 0
--------------------------------------------------------------------------------------------------------------------------------------------

So, what's the problem? what's wrong? It seems I gave the SDCard access rights to the Tasker (even the file is in the internals storage) ... Why Tasker is not able to examine the file?

Could please someone try this command on his/her phone and see whether it works?

Thank you!
 
Here is a small update... When I unchecked the 'Use Root' options, the task was completed successfully, but it returned the '1535272974'.
How should I interpret the number? I expected to receive something in the DATA-TIME format...
What wrong I'm doing now?
 
It is Seconds. Try this …

Dev4
A1: Test File [ Type:Modified Data:Tasker/factory/kids/Dev1.60.apk Store Result In:%temp Use Root:Off ]
A2: Variable Convert [ Name:%temp Function:Seconds to Date Time Store Result In: ]
A3: Flash [ Text:%temp Long:On ]

… Thom
 
Worked! Thanks a lot!
But why it shows that the tested file was created in 1970 while actually it was created in 2017? What's the catch?
 
Worked! Thanks a lot!
But why it shows that the tested file was created in 1970 while actually it was created in 2017? What's the catch?

Possibly the whatever it was that created the file didn't have its date and time set correctly?

1970 is the default year in Unix and Linux systems when they're booted and their calendar/clocks haven't been otherwise set
 
1970 is interesting. Post the Tasker statements you are using …

Long press on Task name
Tap three dots
Tap Export
Tap Description To Clipboard
Paste into message
Post message

… Thom
 
Here is the Task:
----------------------------------------------------------------------
TEST FILE (23)
A1: Test File [ Type:Modified Data:/storage/855D-1A0B/DCIM/Camera/IMG_20170819_143955(1).jpg Store Result In:%mod_sec Use Root:Off Continue Task After Error:On ]
A2: Variable Convert [ Name:%mod_sec Function:Seconds to Medium Date Time Store Result In:%mod_dt ]
A3: Popup [ Title:mod_dt Text:%mod_dt Background Image: Layout:popup Timeout (Seconds):5 Show Over Keyguard:On ]
----------------------------------------------------------------------
But, I did some additional tests...
1) For the new created file, the task reports the modified data and time correctly
2) For some old files, the task reports the correct modified data and time (tested today) and for some of them the wrong Date & Time (1970 year)
3) For all the files, which I tested yesterday, the task reported the wrong date & time (1970). It seems these file were copied to my phone from my PC. Probably this caused them having the wrong (default) date & time. Could it be the cause of the problem - coping the files from one OS to another?

Anyway, thank you for your cooperation and help. I find this forum very useful (at least for Tasker issues :)).
 
Last edited:
It is nagging from a number of years ago. 1970 is the key. There was apparently a problem recording the date/time when the file was created. That's about all I remember.

For files created on your phone I don't think there should be a problem.

… Thom
 
I believe the 1970 date is an indication that the date in the original file is in error.

Documentation says that Test File result is cleared if there is an error.

The seconds are the number of seconds since January 1, 1970.

I am in the Eastern time zone the following reports … 12-31-69 19.00 …

Dev4
A1: Variable Set [ Name:%temp To:0 Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Convert [ Name:%temp Function:Seconds to Date Time Store Result In: ]
A3: Flash [ Text:%temp Long:On ]

… so it is adjusted for time zone.

… Thom
 
Back
Top Bottom