Loop TestFile in Directory, Find Most Recent

106 views
Skip to first unread message

Scott Stuhldreher

unread,
Oct 17, 2015, 2:33:57 PM10/17/15
to Tasker
I'm trying to use Tasker to sort files in a directory and perform an action on the most recent file. At this point, I'll need a step-through as I'm pretty new to Tasker.

I'm would like this to allow me to start a podcast at a certain time. I use Pocket Casts and they implemented Tasker support for intents to play, pause, skip, etc, but it won't work before app is launched, and it can't navigate to different playlists or folders. So I have Pocket Casts auto downloading NPR hourly news summary into a folder.  I'd like Tasker to navigate to this folder, sort it by date modified, and play the newest mp3.

I've gotten this far.

Event>Time>6:30am (no repeat) to 8am (what does this "to" specify?)

Task>ListFiles
Variable : %filesToTest

Does this create an array of the files inside au.com/shiftjelly.pocketcasts/files/PocketCasts/podcasts and assign it to %filesToTest?

If so, can I create a loop that uses test file to test each one to identify most recently modified file?

And If I can identify the most recent file, how can I play the mp3?


Message has been deleted
Message has been deleted

Scott Stuhldreher

unread,
Oct 17, 2015, 3:05:45 PM10/17/15
to Tasker

Ok, It seems I did it.

Event>Time>6:30

Task>List Files> 

Directory : au.com/shiftjelly.pocketcasts/files/PocketCasts/podcasts 

Match : *.mp3 

Variable : %filesToTest

Task>For 

Variable : %filesToTest 

Item : %filesToTest()

Task>Open File 

File : filesToTest(>)

I pieced it togethyer from a StackSocial post here https://android.stackexchange.com/questions/45597/get-list-of-filenames-via-tasker.

Marta Hintz

unread,
Oct 17, 2015, 3:57:50 PM10/17/15
to Tasker
Would be nice to see your completed profile/tasks. I would be interested in setting up something like that.

Rich D

unread,
Oct 17, 2015, 6:08:26 PM10/17/15
to Tasker Google Groups Post


> Ok, It seems I did it.

From what I can tell you are only playing the last file in the array. I do not believe this will always be the most recent file. You will either need to sort the array using the 'test file' action or you can get it in sorted order with a shell command.  I believe it is the 'find' command. If you google 'shell find command' you might be able to get it. I think I have it somewhere and will check when i get some time.  If you post again for help include you exported profile description.  

To post your profile or task here...  Long press on the profile or task name / ( 3 dot menu with 4.0+ ) export / export "DESCRIPTION" to clipboard (not XML)

Any linked tasks will be exported with the profile they are linked to..

To be able to export, The beginner mode needs to be off and the profile needs to be named by you (Not the Tasker listed name.  Tasker will list your profile with the context name if you have not given it one).

Reply all
Reply to author
Forward
0 new messages