Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

To Copy and Move Files Using the File Connector

The File connector can copy and move files or directories on demand.

Example: Copy and Move Operations

       
    
1
2
3
4
5
6
7
8
9
10
11
<file:copy sourcePath="source.txt"
  targetPath="backup"
  overwrite="true|false"
  createParentDirectories="true|false"
  renameTo="renamed.txt"/>

<file:move sourcePath="source.txt"
  targetPath="backup"
  overwrite="true|false"
  createParentDirectories="true|false"
  renameTo="renamed.txt"/>

Notice the targetPath and renameTo parameters:

  • targetPath is the path to the directory into which the file is to be copied or moved. This path must point to a directory.

  • renameTo is an optional parameter that renames the file as part of the operation. This parameter must be a file name, not a path. If this attribute is not provided, the original file name is retained.