Rename Files
Rename Files
This DPU renames files based on a pattern defined in the configuration.
Name | Description | Example |
---|---|---|
Pattern | Regular 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
Name | Type | Data Unit | Description | Required |
---|---|---|---|---|
inFilesData | input | FilesDataUnit | File name to be modified | |
outFilesData | output | FilesDataUnit | File name after modification |
Action | Pattern | Value to substitute |
---|---|---|
Add a suffix ".gml" | ^(.+)$ | $1.gml |
Rename file to "abc" | ^.+$ | abc |
Substitute white spaces | \\s | _ |
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.
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.
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.
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