{"record":{"id":"542904e00a8fb865","repo":"pentaho/pentaho-kettle","slug":"we-can-not-find-folder-0-you-need-to-create-it-before","errorCode":null,"errorMessage":"We can not find folder [{0}]! You need to create it before generating file [{1}].","messagePattern":"We can not find folder \\[(.+?)\\]! You need to create it before generating file \\[(.+?)\\]\\.","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java","lineNumber":1003,"sourceCode":"      parentfolder = getFileObject( filename, getTransMeta() ).getParent();\n      if ( parentfolder.exists() ) {\n        if ( isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"TextFileOutput.Log.ParentFolderExist\",\n              KettleVFS.getFriendlyURI( parentfolder ) ) );\n        }\n      } else {\n        if ( isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"TextFileOutput.Log.ParentFolderNotExist\",\n              KettleVFS.getFriendlyURI( parentfolder ) ) );\n        }\n        if ( meta.isCreateParentFolder() ) {\n          parentfolder.createFolder();\n          if ( isDetailed() ) {\n            logDetailed( BaseMessages.getString( PKG, \"TextFileOutput.Log.ParentFolderCreated\",\n                KettleVFS.getFriendlyURI( parentfolder ) ) );\n          }\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"TextFileOutput.Log.ParentFolderNotExistCreateIt\",\n            KettleVFS.getFriendlyURI( parentfolder ),\n            KettleVFS.getInstance( getTransMeta().getBowl() ).getFriendlyURI( filename ) ) );\n        }\n      }\n    } finally {\n      if ( parentfolder != null ) {\n        try {\n          parentfolder.close();\n        } catch ( Exception ex ) {\n          // Ignore\n        }\n      }\n    }\n  }\n\n\n\n  /**","sourceCodeStart":985,"sourceCodeEnd":1021,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java#L985-L1021","documentation":"When 'create parent folder' is enabled, the step checks the target file's parent folder and creates it if missing. If the folder does not exist and cannot be created, it throws KettleException 'We can not find folder [...]! You need to create it before generating file [...]'.","triggerScenarios":"Parent folder resolution succeeds but the folder is absent and parentfolder.createFolder() fails or is not attempted (e.g. create-parent-folder not enabled), leaving folder==null/not existing at write time.","commonSituations":"Directory deleted between planning and run; permission denied preventing creation; variable substitution produced a bad path; running as user without write access to the parent directory.","solutions":["Manually create the missing output directory before running the transformation","Enable 'Create parent folder' in the step and ensure the connecting user has write permission on the parent path","Verify the substituted filename/path resolves to a valid location"],"exampleFix":"// before: dir missing\n// shell: mkdir -p /output/daily || fail\n// after\nnew File( \"/output/daily\" ).mkdirs(); // or enable meta.setCreateParentFolder( true );","handlingStrategy":"validation","validationCode":"File parent = new File( variableSubstitute( filename ) ).getAbsoluteFile().getParentFile();\nif ( !parent.exists() && !parent.mkdirs() ) throw new IllegalStateException( \"Cannot create folder: \" + parent );","typeGuard":"boolean parentFolderReady( String filename ) { File p = new File( filename ).getAbsoluteFile().getParentFile(); return p != null && ( p.isDirectory() || p.mkdirs() ); }","tryCatchPattern":"try { openNewFile(); } catch ( KettleException e ) { if ( e.getMessage().contains( \"can not find folder\" ) ) { ensureFolderExists(); retryOpen(); } else throw e; }","preventionTips":["Enable 'Create parent folder' in the step dialog","Pre-create directories in the job before the transformation runs","Verify variable-substituted paths with a log line at startup","Run under a user with write permission on the target tree"],"tags":["kettle","pentaho","vfs","directory"],"backgroundTag":"directory-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}