pentaho/pentaho-kettle · error
The function call moveFile throw an error :
Error message
The function call moveFile throw an error :
What it means
moveFile(source, target) moves a file on disk. This error wraps any java.io.IOException raised while performing the move, e.g. missing target directory, cross-filesystem move failure, or I/O problems, and appends the exception text. Note a source file that simply does not exists produces a different message ('file to move [...] can not be found!').
Solutions
- Create the target directory first in the script: new java.io.File(dstDir).mkdirs().
- Verify permissions on source and target paths for the user running Pentaho.
- Close any steps/streams holding the file open before moving (especially on Windows).
- Fall back to copy+delete if rename fails across filesystems, or use the File Management/Move Files step instead of JS.
- Read the appended e.toString() in the message to identify the exact OS-level cause.
Example fix
// before
moveFile('/data/in/file.csv', '/data/out/file.csv'); // /data/out may not exist
// after
new java.io.File('/data/out').mkdirs();
moveFile('/data/in/file.csv', '/data/out/file.csv'); Defensive patterns
Strategy: try-catch
Validate before calling
var srcF = new java.io.File(src), dstF = new java.io.File(dst); if (srcF.exists() && dstF.getParentFile() != null) dstF.getParentFile().mkdirs();
Type guard
function canMove(s, d) { return typeof s === 'string' && typeof d === 'string' && new java.io.File(s).exists(); } Try / catch
try { moveFile(src, dst); } catch (e) { Logger.LogError('moveFile IO error: ' + e.message); /* fallback copy+delete */ } Prevention
- Create target directories before moving
- Ensure no other step/process holds the file open (esp. Windows)
- Check OS permissions for the Pentaho runtime user
- Read the appended IOException text for the exact OS cause
When it happens
Trigger: moveFile(src, dst) where dst's parent directory does not exist, dst is locked/open by another process, permissions deny the move, or the underlying File.renameTo/copy fails with an IOException.
Common situations: Target directory not created before the step runs; file still held open by a previous step on Windows; NFS/Windows cross-drive moves; permission differences between the Kettle user and file owner.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- file to move [ + ArgList[0] + ] can not be found!
- The function call copyFile is not valid.
- The function call copyFile is not valid.
- The function call moveFile throw an error : + e.toString()
- Argument of TRUNC of date has to be between 0 and 5
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/b6b2ce515e42feb5.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2591
// Source file exists...
if ( fileSource.getType() == FileType.FILE ) {
// Great..source is a file ...
boolean overwrite = false;
if ( !ArgList[1].equals( null ) ) {
overwrite = Context.toBoolean( ArgList[2] );
}
boolean destinationExists = fileDestination.exists();
// Let's move the file...
if ( ( destinationExists && overwrite ) || !destinationExists ) {
fileSource.moveTo( fileDestination );
}
}
} else {
Context.reportRuntimeError( "file to move [" + Context.toString( ArgList[0] ) + "] can not be found!" );
}
} catch ( IOException e ) {
throw Context.reportRuntimeError( "The function call moveFile throw an error : " + e.toString() );
} finally {
if ( fileSource != null ) {
try {
fileSource.close();
} catch ( Exception e ) {
// Ignore errors
}
}
if ( fileDestination != null ) {
try {
fileDestination.close();
} catch ( Exception e ) {
// Ignore errors
}
}
}
} else {View on GitHub (pinned to f3058517a1)