utils:rename
utils:rename¶
Rename file(s)
The `pattern` is a regex expression.
Files in the working folder and its sub-folders are looped and the pattern is evaluated against each name (a relative
path to the working folder).
An important thing to note to avoid unexpected matches to the pattern:
The matching of the `pattern` is not enforced to be from the beginning of the string, but the filename is scanned,
looking for the first location where the `pattern` produces a match.
Taking the following working folder structure as an example.
video.mp4
audio.mp4
out/video.mp4
Specifying only `video.mp4` as the pattern would match both, the `video.mp4` in the root of the folder and also in the
`out` sub-folder. To match only the files in the root, use regex expressions at your disposal to make the regex pattern
more specific.
For this specific example, a regex of `^video.mp4` would only match the file at the root of the folder, since it
specifies the name must occur at the very beginning of the string.
Example:
{
"tool": "utils:rename",
"parameters": {
"pattern": '-(?P<lang>\\w+).aac$',
"to": "out/1234567891234567890123456789012_{lang}.aac"
}
}
Above will find all the AAC tracks and use the language extracted from each to
form the output filename. For the input files:
- test-en.aac
- test-es.aac
Following files will be available after tool execution:
- out/1234567891234567890123456789012\_en.aac
- out/1234567891234567890123456789012\_es.aac
Parameter | Properties | Default | Type | Choice | Description |
---|---|---|---|---|---|
pattern | optional | ||||
to | optional |