{"record":{"id":"bec7f81fcdbcc00d","repo":"apache/hadoop","slug":"copying-multiple-files-but-last-argument-dst","errorCode":null,"errorMessage":"copying multiple files, but last argument `\" + dst + \"' is not a directory","messagePattern":"copying multiple files, but last argument `\" \\+ dst \\+ \"' is not a directory","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java","lineNumber":389,"sourceCode":"  }\n\n  public static boolean copy(FileSystem srcFS, Path[] srcs,\n                             FileSystem dstFS, Path dst,\n                             boolean deleteSource,\n                             boolean overwrite, Configuration conf)\n                             throws IOException {\n    boolean gotException = false;\n    boolean returnVal = true;\n    StringBuilder exceptions = new StringBuilder();\n\n    if (srcs.length == 1)\n      return copy(srcFS, srcs[0], dstFS, dst, deleteSource, overwrite, conf);\n\n    // Check if dest is directory\n    try {\n      FileStatus sdst = dstFS.getFileStatus(dst);\n      if (!sdst.isDirectory())\n        throw new IOException(\"copying multiple files, but last argument `\" +\n                              dst + \"' is not a directory\");\n    } catch (FileNotFoundException e) {\n      throw new IOException(\n          \"`\" + dst + \"': specified destination directory \" +\n              \"does not exist\", e);\n    }\n\n    for (Path src : srcs) {\n      try {\n        if (!copy(srcFS, src, dstFS, dst, deleteSource, overwrite, conf))\n          returnVal = false;\n      } catch (IOException e) {\n        gotException = true;\n        exceptions.append(e.getMessage())\n            .append(\"\\n\");\n      }\n    }\n    if (gotException) {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java#L371-L407","documentation":"Error \"copying multiple files, but last argument `\" + dst + \"' is not a directory\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java:389 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["When copying multiple sources, pass an existing directory as the last argument.","Create the destination directory before the copy."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}