TL;DR -> If you don't care about my rambling/background information; skip to the task I wrote out/attached and tell me why it is not writing anything to the text file?
I was trying to solve a problem using a tasker task which would call itself recursively in a loop (traversing folders). I have since discovered I don't need to do something so complex, but I would like to know why it was failing still.
My issue is that I need to trigger a media scan of some downloaded files. The program doing the downloading doesn't scan them (and I have reported it to the dev who is "working on it") so when I plug my phone into my PC I can't see the files.
In the past I could use the tasker media scan function to scan a folder and it would nicely scan that folder and all its subfolders recursively. I swear (maybe I am crazy) that sometime in the recent past this stopped working (I KNOW android changed media scanning functionality in their framework which is why my downloading app broke in the first place) and you had to scan files individually (folders would never work).
So I was fed up today with this other downloading app not scanning its downloaded files and decided to use tasker to scan my downloads folder. Since attempting this I have discovered that media scan in tasker was fixed (maybe it was never broken) to recursively scan folders again, so all my work was for nothing. But I could not figure out why it was failing. The task is super super simple. But it would just stop randomly and not even successfully scan the files on the top level of the directory (and you would think at least those would work since they do not require a recursive call).
Here is my task typed out, and I have attached the xml backup. I also changed the else conditional to just write the filename to a text file (instead of scan the media since that would be hard for anyone to verify if the media scan worked). My test text file is always empty even excluding items in the top level directory.
Task Name: Media Scan Folder
1. List Files %para1 into $files
2. For $file in $files()
3. Test File Type into $file_type
4. if($file_type~dir)
5. Call Media Scan Folder; Parameter 1 = $file //recursive call
6. Else if ($file_type~file)
7. Write $file to test.txt
8. End If
9. End For
No matter what priority I set for the subtask, nothing gets scanned (written to the test output file) at all.
I was using flash alerts to try and do some debugging but I could not figure out why it wasn't working. It just stops.
Again, I have solved my problem by simply calling the media scan function on the folder itself (now that I realize that works again), but I am curious what about this super simple task is failing. I must be doing something extremely silly, this should be so simple by the sounds of the tasker guide.
Thanks for any help,
B.