The outputPrefix option

Almost every Sejda task generating multiple output files supports a –outputPrefix option which can be used to instruct Sejda on how multiple output files have to be named.

The simplest case where the option is not provided usually results in the Sejda task generating output files with the same name as the input ones but this is not always the case. Tasks like splits have a single input file and they generate multiple files in which case output names may be prefixed with a sequential number or a page number to avoid each output overriding the previous one.

By specifying a string as –outputPrefix the generated file names will have the prefix prepended and again, some of the tasks may have a number prefix to ensure uniqueness of the names.

Some special keywords can be used as placeholders in the supplied prefix to be replaced with dynamic values during the task execution. This feature is derived from the so called complex prefixes in pdfsam-console and it slightly extends the capabilities of the pdfsam-console. These keywords are a powerful tool giving the user a level of flexibility to define a template for the name of the generated output files. Some of them have a meaning only in some specific context (like bookmark name during the splitbybookmarks task) and are treated as simple strings by tasks where they can’t have a dynamic value.

[CURRENTPAGE]

The [CURRENTPAGE] placeholder ensures unique output filenames and it’s replaced with the current page number. The number of digits of the generated prefix can be specified appending any number of ‘#’ at the prefix name, inside square brackets.

Ex. the prefix [CURRENTPAGE###] will generate prefixes like ‘001’, ‘002’…

[TIMESTAMP]

The [TIMESTAMP] placeholder ensures unique output filenames and it’s replaced with the current date and time. Time has milliseconds precision and the replaced variable will be something like “20090706_152643712” that is “YYYYMMDD_HHmmssSSS”.

[FILENUMBER]

The [FILENUMBER] placeholder ensures unique output filenames and it’s replaced with a file number according to the output order. The number of digits of the generated prefix can be specified appending any number of ‘#’ at the prefix name, inside square brackets. A starting number can be appended at the prefix name inside the square brackets.

Ex. the prefix [FILENUMBER###] will generate prefixes like ‘001’, ‘002’…
Ex. the prefix [FILENUMBER13] will generate prefixes like ’13’, ’14’…
Ex. the prefix [FILENUMBER###13] will generate prefixes like ‘013’, ‘014’…

[BASENAME]

The [BASENAME] placeholder does not ensure unique output filenames and it must be used together with other placeholders ensuring unique names. It’s replaced with original name of the input document.

[BOOKMARK_NAME]

The [BOOKMARK_NAME] placeholder is replaced only when splitting by bookmarks level. It ensures unique output filenames (unless two or more bookmarks have the same name). It’s replaced with the bookmark name. Some characters of the bookmark name could be stripped if they are not valid character for a file name.

[BOOKMARK_NAME_STRICT]

The [BOOKMARK_NAME_STRICT] placeholder behavior is the same as the [BOOKMARK_NAME] placeholder with the difference that every character that is not a letter or a number is stripped from the output name. This placeholder is less precise then is sibling but it should guarantee more robustness on different file systems stripping every potential invalid char.