## Advanced features

Here are a few "tricks" and information that may be useful :

- The character * (star)
- Modifiers concatenation
- Modifiers precedence
- Escape character
- New name path
- Environment variables
- Include
- Sub-expressions
- Variables as parameters

#### The character * (star)

The character (`*`) can be used in an expression. Placed before the '.' delineating the base name from the extension, it will represent the base name, placed after it will represent the extension.
It is not a variable and its value can not be modified.

#### Modifiers concatenation

You can "concat" as many modifiers `"()"` and `"[]"` as you want. They are evaluated from left to right, the output of the first becoming the input of the second.

Let's examine, step by step, an example on `"autoexec.bat"` :
`%Lb("au","au-")(s/e/e_/g)[2](5).%e`

> `

> %b | on | autoexec.bat | gives | autoexec
> ("au","au-") | on | autoexec | gives | au-toexec
> (s/e/e_/g) | on | au-toexec | gives | au-toe_xe_c
> [2] | on | au-toe_xe_c | gives | toe_xe_c
> (5) | on | toe_xe_c | gives | xe_c
> the modifier 'L' | on | xe_c | gives | Xe_c
> add fixed text "." | on | Xe_c | gives | Xe_c.
> add "%e" (extension) | on | Xe_c. | gives | Xe_c.bat

> `

#### Modifiers precedence

Many different modifiers can be associated to a variable. Here is the order followed for their evaluation :

1. Special modifier : `"{}"`
2. String modifiers : `"()"` and `"[]"`
3. Character conversion
   1. `#` : '%XX' characters
   2. `&` : UTF8-ascii to UTF8
   3. `@` : Accented characters to standard ASCII
4. Case modifier

#### Escape character

You may want to use "special" characters like `'('`, `';'`, `'*'` ... in an expression. To suppress the "special" status of a character, put a `'\'` (backslash) before it.

For example, to rename the file : `Image.jpg` to `Image(2).jpg` with the expression : `%b(2).%e`
Use : `%b\(2).%e`

#### New name path

Except to use absolute paths, new name paths are always relative to Siren's current directory.

Be careful when you are working with the sub-directories loaded (button ).

For example :

- if Siren's current directory is `"\photo"`
- if the selected file current name is `"2011\paris.jpg"`
- if its new name is `"..\paris.jpg"`

Then, after renaming, `"paris.jpg"` will be in `"\"` and not in `"\photo"`.
`".."` is relative to `"\photo"` and not to `"2011"`.

#### Environment variables

You can use any variable that is part of the process environment.
Their names have to be specified this way : `${NAME}`
For example : `${PATH}`

A complete list is available in the "Completion" window.

#### Include

You can use your favourite expressions like a "library". All written and saved "code" becomes reusable.
The favourite name must be specified this way : `#{"exp"}`

You can use this only outside of a variable and its modifiers.

For example, if you've got a favourite named `"img"` associated to the expression `"Image %n"`, you can reuse it these ways :

> `#{"img"} - Garden.%e
> File - #{"img"} - Zoo.%e`

It is possible to go a bit further.
The `"img"` favourite ends with `"%n"` which is a variable accepting specific parameters. For example : `"{2,10}"`.

If the expression `"#{"img"}{2,10} - %f"` is applied to `"Garden.jpg"` :

> `

> #{"img"}{2,10} - %f | gives | Image %n{2,10} - %f
> Image %n{2,10} - %f | gives | Image 10 - Garden.jpg

> `

Of course, you can do this with other modifiers.

#### Sub-expressions

An expression itself can be made up of expressions (or sub-expressions).

By separating them with `';'` (semicolon) they can be chained. The "New name" created by one becomes the "current name" in the next.

For example, for `"PHOTO CLOWN 1.JPG"`

> `

> %lf;%b("clown","CLOWN").%e | gives | photo CLOWN 1.jpg
> %b[3," "].%le;%N{5,10}.%e | gives | 00011.jpg

> `

#### Variables as parameters

In an expression, any parameter can be replaced with a variable and all its modifiers.

This applies to parameters in :

- Variable modifiers : `{}`, `()` and `[]`
- Environment variables : `${}`
- Include : `#{}`
- ...

For example, the following expressions are correct :

> `

> %f("Text",%At) | Will replace, in the name, the text "Text" with the audio title
> %f("Text",%uAt(1,5)) | Will replace, in the name, the text "Text" with the uppercase first five characters of the audio title
> %Rs{%Rn{1,1,10}} | Will generate a random string of a random length between one and ten characters

> `

It can be interesting to use this feature with the `%T` variable.
For example, `%T1{%fc}` will contain the first line of the treated file.

Note : In certain limits, file lines used with `%T` are kept in memory by Siren. Therefore the amount of memory used will depend on the number of files treated.