Purpose

The module MakeName generates an output filename from an input name and an output template.

Special variables in the output template string are replaced by values derived from the input filename.

Usage

Enter the input filename in the Input Name field or select an existing file or directory using the Browse… button.

Enter the template string for the output name in the Output Template field, using the $-variables listed below. If the output template contains the $b or $e variable, the extension pattern, i.e. the definition of what should be considered an extension, must be specified in the Extensions field.

The Regular Expression check box specifies whether the extension pattern contains regular expressions or simple wildcard strings (using ‘*’ and ‘?’). Predefined extension patterns can be set by pressing one of the Set Pattern buttons.

If you want to use DICOM tag values of an image in the output name, you can connect the image to the input field and specify the corresponding DICOM tags in the Variables-Panel.

The Output Name field contains the name generated from the output template by replacing the template variables with their values. The output name is updated automatically when any of the other fields are changed. However, if the filename counter ($#) is used, make sure to press the Update button before using the output name (e.g. for saving a file). Otherwise, the output name might refer to an existing file that has been created since the last update.

Details

Output Template Variables

Variable Function
$n Complete input name
$f Filename portion of input name
$d Directory portion of input name
$e Extension of input name, i.e. the trailing part matching the extension pattern
$b Base name portion of input name, i.e. $f without extension
$# A filename counter chosen such that the resulting filename does not exist
$S, $T User strings defined in the Variables panel
$A, $B, …, $F The contents of the corresponding Value field in the Variables panel
$$ The ‘$’ character

Filename Counter Formatting

The counter variable $# may be used with an additional length specifier in the form $n#, where n is the minimum number of digits used for the counter string (padded with trailing zeros, if necessary). If n starts with the digit ‘0’, the counter is zero-based, otherwise one-based.

Extension Patterns

Several extension patterns may be separated by spaces. Extension patterns are either wildcard strings or regular expressions.

Wildcard Strings

The special characters ‘*’ and ‘?’ represent any sequence of zero or more characters, and a single character, resp.

Regular Expressions

For the syntax of regular expressions, please consult the JavaScript documentation. It is not necessary to include the regular expression in slashes (/../) or to terminate it with a ‘$’ character. The most important special characters are:

Character Meaning
. (Decimal point) Any character
* Zero or more occurrences of the preceding character
+ One or more occurrences of the preceding character
? Zero or one occurrence of the preceding character
[...] Character set

Windows

Default Panel

../../../Modules/Macros/FileHandling/mhelp/Images/Screenshots/MakeName._default.png

Input Fields

inImage

name: inImage, type: Image, deprecated name: inputDicomImage

Parameter Fields

Field Index

dicomTagA: String dicomValueC: String Regular expression: Bool
dicomTagB: String dicomValueD: String Template: String
dicomTagC: String dicomValueE: String Trim spaces: Bool
dicomTagD: String dicomValueF: String Update: Trigger
dicomTagE: String Extensions: String User String $S: String
dicomTagF: String Name (inputName): String User String $T: String
dicomValueA: String Name (outputName): String  
dicomValueB: String Predefined: Enum  

Visible Fields

Name (inputName)

name: inputName, type: String

The filename defining the output template variable values.

Extensions

name: extensions, type: String, default: \.[^.]*

The extension pattern defining the extension part of the input name.

Regular expression

name: extRegExp, type: Bool, default: TRUE

If this is checked, the extension pattern is defined using a regular expression.

Template

name: outputTemplate, type: String

The template string defining the output name, possibly using output template variables.

Name (outputName)

name: outputName, type: String

The resulting output filename. Press Update to make sure it is up-to-date.

Update

name: update, type: Trigger, deprecated name: updateOutput

Press to update the output file name.

Predefined

name: predefined, type: Enum, default: void

Defines a predefined file type.

Values:

Title Name
void void
All All
Images Images
Dicom Dicom

User String $S

name: userStringS, type: String, deprecated name: inputString1

The values in these fields can be used in the output template by inserting $S.

User String $T

name: userStringT, type: String, deprecated name: inputString2

The values in these fields can be used in the output template by inserting $T.

Trim spaces

name: trimSpaces, type: Bool, default: TRUE, deprecated name: eliminateTrailingSpaces

Some Dicom values contain (useless?) trailing space characters. To remove these (in all field values) enabled this option (default).

Hidden Fields

dicomTagA

name: dicomTagA, type: String, default: PatientsName

dicomTagB

name: dicomTagB, type: String, default: PatientID

dicomTagC

name: dicomTagC, type: String, default: InstitutionName

dicomTagD

name: dicomTagD, type: String, default: Modality

dicomTagE

name: dicomTagE, type: String, default: AcquisitionDate

dicomTagF

name: dicomTagF, type: String, default: AcquisitionTime

dicomValueA

name: dicomValueA, type: String

dicomValueB

name: dicomValueB, type: String

dicomValueC

name: dicomValueC, type: String

dicomValueD

name: dicomValueD, type: String

dicomValueE

name: dicomValueE, type: String

dicomValueF

name: dicomValueF, type: String