Rename files: remove a prefix from file names

General

In a given folder, there are several thousand files, which are intended to be sorted alphabetically. The problem is that the vast majority of those files begin with a "BP." prefix, so the files are not sorted alphabetically.

This article will show how to process all the files but only the files that start with the "BP." prefix can be renamed by omitting that prefix.

As input folder we will have the source files, as output we will have all the files that can be sorted alphabetically (since the prefix, which was present in some files will be gone).

Configuration

Create a new File Processor channel. This is the configuration of the channel:

  1. General: give the channel a Title:: rename files and remove prefix.
  2. Schedule: leave as default or chance to Don't schedule if you want to start the processing manually.
  3. Input: select for Input Type: Local/Network and for Path: choose your source file path e.g. c:\input\
  4. Input Filter: don't use this. We are going to process all files.
    A first reaction might be to put a filter here that would select all files with the "BP." prefix. But that would have the effect of not processing the other source files in the input folder. The idea is to process all the source files so that they too will be in the output folder. So we will make a choice in a different way as to which files to rename or not.
  5. Conversion: click Add Converter.
    Select Converter: Rename files.

    Rename to: click Add > Property (Parameter)
    Select Property: File name.
    Click Add result adjuster and choose for Option: Regex.
    Regular Expression: (?<=BP[.]).* This will select the part of the file name without the BP. prefix.
    Result to use: Full match.
    Click OK to close this dialog.
    Image

    Now for Condition: click Add > Property (Parameter).
    Select Property: File name.
    Click Add result adjuster and choose for Option: Regex.
    Regular Expression: ^BP[.].* This is our filter that will only rename files starting with the "BP." prefix.
    Result to use: Full match.
    Click OK to close this dialog.
    Image

    The converter dialog should look like this now:

    Image
    (You can double click the text $[FileName-] to edit an existing recognition.)

    Image

  6. Impersonation: not being used.
  7. Output: select Output Type: Local/Network and for (Network) Path: select the destination folder, e.g. C:\output.
    Existing files: Create new file.
  8. Post-Action: (Success), leave as default: Process -> Delete (input file) (Type: Method).
  9. Click OK, to close the Channel Options.

Testing

  1. Put the files in the source input folder (e.g. C:\input)
  2. Click Start.
  3. If all is fine, all files will be in the destionation folder (e.g. C:\output) and the prefix of files would have been renamed.

input:

C:\input
a.txt
b.jpg
BP.c.jpg
BP.d.jpg
BP.xyz.psd

output result:

C:\output
a.txt
b.jpg
c.jpg
d.jpg
xyz.psd