Script examples

This page shows some short examples of the most important functions provided by the built-in scripting language.

Copy/Paste the examples into an action Script and use Menu->Execute to test the action. The output will be written to the Automagic Log accessible with Menu->Log.

String operations

Test if a variable contains a value (exactly)

Test if a variable partly contains a specific text

Test if a string matches a regular expression (see Regular expressions)

Find the content of the groups in a regular expression

Create a list of lines from a multiline text

Create a list of words

Extract the contents of an HTML element

Modify a phone number from 00411234567 to 0 0 4 1 1 2 3 4 5 6 7 for better text to speech output

Test if a file name ends with the suffix .mp3

Strip off the file extension

Convert a text to upper case

Remove whitespace around a text

Replace variables in a string literal

Date & Time

Get and format the current date + time (see Date Format Pattern)

Create a specific date

Duration between two dates

Get the date from a text value and reformat

Modifying a date


Creating lists

Adding elements to a list

Sorting the values in a list

Reversing the values in a list

Finding the index of an element

Remove an element at a specific index

Inserting an element into the list

Test if an element is in the list

Adding an element if it is not in the list yet

Removing value "c" from the list

Testing the number of elements in a list

Adding an element to the list but keeping the list 4 element long

Looping over the elements of a list


Creating an empty map

Adding key/value-pairs to a map

overwriting an entry

Accessing the value for a key

get a list of all keys and values in map


The examples in this section use the following input XML (in variable input):
        <title>Book 1</title>
        <pages format="A4">745</pages>
        <title>Book 2</title>
        <pages format="A5">120</pages>
        <title>Book 3</title>
        <pages format="letter">1230</pages>

Extract book titles

Extract the price of the books

Print the format of Book 1

Print Book title of book with page format A5

Number theory

RSA (uses experimental functions)

Diffie Hellman (uses experimental functions)