Read directory contents to var

61 views
Skip to first unread message

onezero1010101

unread,
Aug 17, 2010, 1:53:59 PM8/17/10
to Tasker
Is it possible to read a directory contents to a variable to be able
to write it to a file. Wanting to be able to scan my wallpaper folder,
and randomly pick a file to set as wallpaper. I don't think it should
be a problem, once I get the file created of filenames. If someone
has better way to accomplish this, I am open to suggestions as well.
Thanks

BossMan

unread,
Aug 18, 2010, 4:25:12 AM8/18/10
to Tasker
I don't think you can list directories at the moment.

You can call an ASE script tough. It could run "ls" command and write
the output (list of files) to a file. The you could read that file in
Tasker and do the rest.

BR,
A.

onezero1010101

unread,
Aug 18, 2010, 7:34:00 AM8/18/10
to Tasker
What exactly is an ASE script? I have ConnectBot (Telnet/SSH Terminal
Client) and can open a local shell prompt. I could probably generate
a list manually, but really don't want to have to do that each time I
modify the directory structure.

BossMan

unread,
Aug 18, 2010, 8:54:06 AM8/18/10
to Tasker
http://code.google.com/p/android-scripting/
Once you create your script, you can run it from Tasker.

BR,
A.

onezero1010101

unread,
Aug 18, 2010, 3:28:41 PM8/18/10
to Tasker
Ok, I have a script to ls the contents to a file. Now I need to
determine how many items are in the file, how do I count the lines? I
have attempted to loop tasker, to read a line, then increase a
linecount var, goto 1, and repeat till eof. When EOF, it ends loop
and supposed to save the variable with total lines, so I can set the
min / max values for var random, to pick a random line to read with
read file. Problem is, the loop is SLOW. I have alot of files in the
folder, so its taking forever to count the lines. Is there anything
to count lines in a file?

Or, is it possible using ASE script, to count the items in folder, or
count lines in file?

Tried using ls | wc -l (but wc does not have permission to run)

Thanks

BossMan

unread,
Aug 19, 2010, 4:37:58 AM8/19/10
to Tasker
If you use bash/shell, wc -l is the easiest option. If you have
busybox installed, try running busybox wc -l.

If this doesn't work, you should be able to walk-around using perl/
python script.

BR,
A.

onezero1010101

unread,
Aug 20, 2010, 10:18:16 AM8/20/10
to Tasker
Well not being rooted, wc command does not work using shell. Do you
have any idea how I would go about that with python? I loaded that,
have not loaded perl yet, but do not have much experience with either
one.

BossMan

unread,
Aug 20, 2010, 10:37:37 AM8/20/10
to Tasker
Reply all
Reply to author
Forward
0 new messages