Home > docs > plugins v2 > Files Task
The files
task provides methods to handle local files within the working directory
of a Concord workflow process.
To be able to use the task in a Concord flow, it must be added as a dependency:
configuration:
dependencies:
- mvn://com.walmartlabs.concord.plugins.basic:file-tasks:2.14.0
This adds the task to the classpath and allows you to invoke it in any flow.
The exists(path)
method returns true when a given path exists within the working
directory.
- if: "${files.exists('myFile.txt')}"
then:
- log: "found myFile.txt"
The notExists(path)
method returns true
when a given path does not exist
within the working directory.
- if: "${files.notExists('myFile.txt')}"
then:
- throw: "Cannot continue without myFile.txt!"
The moveFile(src, dstDir)
method moves a file to a different directory. The returned
value is the new path.
- set:
myFile: "${files.moveFile('myFile.txt', 'another/dir)}"
# prints: "another/dir/myFile.txt"
- log: "${myFile}"
The relativize(pathA, pathB)
method returns a relative path from the first
path to the second path.
- set:
relativePath: "${files.relativize('subDirA/myscript', 'subDirB/opts.cfg')}"
- log: "${relativePath}"
# prints: '../../subDirB/opts.cfg'