Filename Cleanse
This task uses regex (Regular Expressions) to alter filenames. When transferring files to another repository, if that destination repository has conditions for file names, this task can be used to clean up the names so they can be migrated to the output location without fail. Common use cases are clearing unwanted characters, such as whitespace, or non-alphanumeric characters.
For example, if your documents have spaces in the file name, and the repository you are migrating them into does not allow spaces in file names, you would use this task to remove the space or replace them with an acceptable character like an underscore. This task can also be used to clean up unorthodox characters like emojis and %.
Configuration
To use this task go to the task tab in your job. Select the task from the drop down and click the plus circle to configure the task. Click done after making any changes to save.
Condition check
It will execute the task when the condition's result is 'true', 't', 'on', '1', or 'yes' (case-insensitive), or run on all conditions if left empty. This condition is evaluated for each document, determining whether the task should be executed based on the specified values.
Example: If I only want to run this task for PDF documents I would use the expression: equals('#{rd.mimetype}',"application/pdf")
Regex to Match
The regex pattern to search for in the filename. In this field you will enter The default regex condition to match for this task is [^a-zA-Z0-9 \.]+ Using this condition will tell 3Sixty to look for any character that isn’t either a number, letter, space, backslash or period.
The default value matches any character that isn't a letter, number, space or period an unlimited number of times.
Replacement
Replacement for matches. In this field you will enter what you want to replace any matching character 3Sixty finds. Anything that is not a number or letter or space or backslash space or leave the replace field blank to delete any non friendly characters like emojis or any other characters that might not be allowed in typical file name use. When a target repository does not support irregular characters.
Note: EXAMPLE - ALPHANUMERICS
The pattern for alphanumeric characters is
[a-zA-Z0-9], or if you wish to include underscores \w
To select for non-alphanumeric characters we add the carat (^) before the pattern, so
^[a-zA-Z0-9]
The character simply translates to "Not", so it negates whatever is after it.
Note: EXAMPLE - CLEARING UNWANTED SPACES
The pattern \s is regex shorthand for "spaces". If you're worried about tabs, line breaks etc. add an asterisk (*) after the pattern for what is called "greedy" selection.
Adding this as your regex and setting the replacement as ''
Examples
Scenario 1: Remove spaces from file name
Using the following configuration if your file name is Sample File after integration it will be converted to SampleFile.
-
Regex to match: [^a-zA-Z0-9\.]+
-
Replacement Text: (leave blank)
This regex condition will take the space in the file name and remove it during the integration.
Note we have removed the space from the default Regex so we can search for anything that is not a number, letter, backslash, or period.
Scenario 2: Replace _ and % in the file names with a space
You have files with _ and % in the file name and you want to replace them with a space.
-
Regex to match: [_%]
-
Replacement Text: (the space character)
This Regex Condition will replace any _ and % in a file name with a space.
Scenario 3: Replace the word Test with the word Sample in all file names
You have several files with the word Test in them and you want to replace it with the word Sample
-
Regex to match: Test
-
Replacement Text: Sample
This will replace the word Test with the word Sample in any file name 3Sixty processes for this job. Note Regex is case sensitive. It will only replace exact matches.
API Keys
Processor: filenameCleanseTask
Key |
Display Name |
Type |
---|---|---|
use_condition | Check a condition before executing this task. | Boolean |
task_condition |
Condition |
String |
task_stop_proc |
Stop Processing |
Boolean |
fcjt_regex |
Regex to Match |
String |
fcjt_replace |
Replacement Text |
String |