Script actions

Post your questions and help other users.

Moderator: Martin

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Script actions

Post by bogdyro » 09 Apr 2015 15:43

Hello. I have a flow to get the creation time of some files in a folder. So I create an action init variable file list. Then I use the action 'script' and foreach variable in the file list I would have to call init variables file info. Is it possible to call this action or any other through code? That would be great.
thanks

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script actions

Post by Martin » 10 Apr 2015 11:56

Hi,

No, scripts only support to read and modify variables but don't allow to execute arbitrary actions. You would have to create a loop in your flow and call Init Variables File Info for each file.

Regards,
Martin

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Script actions

Post by bogdyro » 10 Apr 2015 15:53

Bummer.any plans of changing that?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script actions

Post by Martin » 12 Apr 2015 10:57

No, sorry, I have no plans to extend action script to execute arbitrary actions in the foreseeable future. However I could extend action Init Variable File List to return also size and date for each file or I could add a script function to get file attributes. You could also use Execute Command: ls -l to get a list of all files with additional file attributes and process the result entirely within a script.

What's the end goal of the flow?

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Script actions

Post by bogdyro » 13 Apr 2015 20:59

The end result would be would processing on each file name and copying them one by one. Where could I get some info on what kind of commands i can issue. I don't know what Is -l means.

lchiocca
Posts: 69
Joined: 15 Aug 2013 10:11

Re: Script actions

Post by lchiocca » 15 Apr 2015 06:31

Hihi.. it's no *I*s.. but a lowercase L. Its the standard unix command to list files.... the equivalent to the dos "dir" command.

Here to help you out:

Code: Select all

$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuSUX nor --sort.

  -a, --all                  do not hide entries starting with .
  -A, --almost-all           do not list implied . and ..
  -b, --escape               print octal escapes for nongraphic characters
      --block-size=SIZE      use SIZE-byte blocks
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information)
                               with -l: show ctime and sort by name
                               otherwise: sort by ctime
  -C                         list entries by columns
      --color[=WHEN]         control whether color is used to distinguish file
                               types.  WHEN may be `never', `always', or `auto'
  -d, --directory            list directory entries instead of contents
  -D, --dired                generate output designed for Emacs' dired mode
  -f                         do not sort, enable -aU, disable -lst
  -F, --classify             append indicator (one of */=@|) to entries
      --format=WORD          across -x, commas -m, horizontal -x, long -l,
                               single-column -1, verbose -l, vertical -C
      --full-time            list both full date and full time
  -g                         (ignored)
  -G, --no-group             inhibit display of group information
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --si                   likewise, but use powers of 1000 not 1024
  -H                         same as `--si' for now; soon to change
                               to conform to POSIX
      --indicator-style=WORD append indicator with style WORD to entry names:
                               none (default), classify (-F), file-type (-p)
  -i, --inode                print index number of each file
  -I, --ignore=PATTERN       do not list implied entries matching shell PATTERN
  -k, --kilobytes            like --block-size=1024
  -l                         use a long listing format
  -L, --dereference          list entries pointed to by symbolic links
  -m                         fill width with a comma separated list of entries
  -n, --numeric-uid-gid      list numeric UIDs and GIDs instead of names
  -N, --literal              print raw entry names (don't treat e.g. control
                               characters specially)
  -o                         use long listing format without group info
  -p, --file-type            append indicator (one of /=@|) to entries
  -q, --hide-control-chars   print ? instead of non graphic characters
      --show-control-chars   show non graphic characters as-is (default
                             unless program is `ls' and output is a terminal)
  -Q, --quote-name           enclose entry names in double quotes
      --quoting-style=WORD   use quoting style WORD for entry names:
                               literal, locale, shell, shell-always, c, escape
  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
  -s, --size                 print size of each file, in blocks
  -S                         sort by file size
      --sort=WORD            extension -X, none -U, size -S, time -t,
                               version -v
                             status -c, time -t, atime -u, access -u, use -u
      --time=WORD            show time as WORD instead of modification time:
                               atime, access, use, ctime or status; use
                               specified time as sort key if --sort=time
  -t                         sort by modification time
  -T, --tabsize=COLS         assume tab stops at each COLS instead of 8
  -u                         with -lt: sort by, and show, access time
                               with -l: show access time and sort by name
                               otherwise: sort by access time
  -U                         do not sort; list entries in directory order
  -v                         sort by version
  -w, --width=COLS           assume screen width instead of current value
  -x                         list entries by lines instead of by columns
  -X                         sort alphabetically by entry extension
  -1                         list one file per line
      --help                 display this help and exit
      --version              output version information and exit

By default, color is not used to distinguish types of files.  That is
equivalent to using --color=none.  Using the --color option without the
optional WHEN argument is equivalent to using --color=always.  With
--color=auto, color codes are output only if standard output is connected
to a terminal (tty).

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script actions

Post by Martin » 15 Apr 2015 18:35

The commands available depend on each version of Android but this page is a good starting point: https://github.com/jackpal/Android-Term ... -Reference
Some interesting ones are also listed here (most require a rooted device): DIY-Actions: Execute Command, Execute Root Command

I've added a new option to action Init Variable File List to include some file attributes in the next update of Automagic. Instead of listing just the file name the list now contains a list for each file that contains file name, type (file or dir), size and last modified time so you could probably achieve what you want when you are comfortable with scripting.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Script actions

Post by bogdyro » 17 Apr 2015 04:03

Hi. I tried the -ls command in terminal emulator. I have a HTC one m8 phone running lollipop. Other than the -a argument, nothing works. For example
ls -help doesn't work
ls -t doesn't work
I get argument not found
Anyway,I can still process the output in a script. Usefull function.
@Martin...so each object in a file list will now be a list with each files' details. Right?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script actions

Post by Martin » 18 Apr 2015 11:19

The commands provided by Android are usually very limited in comparison to the ones available on a current desktop machine. I often connect my device to a desktop machine and use adb shell to execute commands on the phone since it's much quicker to work with a proper keyboard.
You can also install busybox on the device to get a plethora of new commands available.

Correct, each object in the list will be a list containing the details of one file.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Script actions

Post by bogdyro » 19 Apr 2015 00:48

Hi. I have a new problem now. Trying to execute a command (ls -l) with the working directory provided by a variable previously set in a input dialog. Entering {variable} in the 'working directory' field doesn't work. I get an error in the log - no such file/directory. Maybe a bug?
thanks

Post Reply