Rename Files

Description

Rename Files (uv-t-filesRenamer):

This DPU renames files based on a pattern defined in the configuration.

Configuration Parameters

NameDescriptionExample
PatternRegular expression used to match a string to replace in file name. This value is used as a replace part (second argument) in SPARQL REPLACE.\\s
Value to substitute Value to substitute, it can refer to groups that have been matched by the 'Pattern' parameter. This value is used as a substitute part (third argument) in SPARQL REPLACE.-
Use advanced mode If checked, the indicated value to substitute is considered an expression instead of a string. This enables the use of SPARQL functions, but the result must be in the form of a string.struuid()

Inputs and Outputs

NameTypeData UnitDescriptionRequired
inFilesDatainputFilesDataUnitFile name to be modified(tick)
outFilesDataoutputFilesDataUnitFile name after modification(tick)

Notes

List of Useful Commands with Advanced Mode Unchecked

ActionPatternValue to substitute
Add a suffix ".gml"^(.+)$$1.gml
Rename file to "abc"^.+$abc
Substitute white spaces\\s_

Examples

Download File, Rename it, Upload it Again

The following image shows a pipeline which downloads a file from a server, renames it, and uploads it again. The Rename Files DPU takes the downloaded file as input and produces the renamed file as output. The configuration of the DPU is shown in the image below.




Download ZIP-File, Unzip it and Remove White Spaces from the File Names

The following image shows a fragment of a pipeline which downloads a file, unzips it and then uses the Rename Files DPU to replace white spaces in the file names with "_". The configuration of the DPU is shown in the image below.


Use the Advanced Mode to Replace the Txt File Extension With a UUID

The following image shows a fragment of a pipeline which downloads a file and uses the Rename Files DPU with the advanced mode to replace the file name with a UUID. The relevant input and output parameters of this DPU are:

Input filename: file.txt
Regex: .*\\.txt
Replacement: struuid()
Output filename: 4528d703-f330-4f51-a993-e09a9e74ec12

The configuration of the DPU is shown in the image below.


Use the Advanced Mode to Add a Timestamp to File Names

The following image shows a fragment of a pipeline which downloads a file and uses the Rename Files DPU with the advanced mode to add a timestamp to the file name. The relevant input and output parameters of this DPU are:

Input filename: file.txt
Regex: (.*)(\\.txt)
Replacement: concat("$1-", str(now()), "$2")
Output filename: file-2018-11-19T09:43:02.590+01:00.txt