Moves (renames) the file passed as input to a destination path. Supports overwriting and auto-incrementing the file name to avoid collisions.
- Service:
CleverAge\ProcessBundle\Task\File\FileMoverTask
string: path of the file to move. An \UnexpectedValueException is thrown if it does not exist.
string: the final destination path of the file.
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
destination |
string |
X | Destination path. If it is an existing directory, the original file name is kept | |
overwrite |
bool |
false |
Allow overwriting an existing file at destination (otherwise an exception is thrown) | |
autoincrement |
bool |
false |
If the destination file exists, add or increment a numeric suffix before the extension (e.g. file-1.csv, file-2.csv) |
- Archive processed files
# Task configuration level
move_file:
service: '@CleverAge\ProcessBundle\Task\File\FileMoverTask'
options:
destination: '%kernel.project_dir%/var/data/archive/'
autoincrement: true- Underlying method is Symfony
Filesystem::rename().