Skip to main content

Rename Files

Abstract

Rename Files

DescriptionRename Files (uv-t-filesRenamer):

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

Configuration Parameters

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

(tick)

outFilesData

output

FilesDataUnit

File name after modification

(tick)
NotesList of Useful Commands with Advanced Mode Unchecked

Action

Pattern

Value to substitute

Add a suffix ".gml"

^(.+)$

$1.gml

Rename file to "abc"

^.+$

abc

Substitute white spaces

\\s

_

ExamplesDownload 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.

24576283.png
24576278.png
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.

24576281.png
24576280.png
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.

24576277.png
24576275.png
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

24576277.png
24576284.png