<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Move file from one HDFS directoy to another using scala/java in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201910#M78626</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3369/gnovak.html" nodeid="3369"&gt;@gnovak&lt;/A&gt; thanks for you time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
    <pubDate>Fri, 01 Jun 2018 00:39:16 GMT</pubDate>
    <dc:creator>rahulsmtauti</dc:creator>
    <dc:date>2018-06-01T00:39:16Z</dc:date>
    <item>
      <title>Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201901#M78617</link>
      <description>&lt;P&gt;I've files in one hdfs folder and after checking few things i wanted to move that file to another directory on hdfs.&lt;/P&gt;&lt;P&gt;Currently i am using filesystem object with rename it is doing the job but it is actually renaming the file with complete path. &lt;/P&gt;&lt;P&gt;Do have any other way to do it?&lt;/P&gt;&lt;P&gt;Appriciate your help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 14:41:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201901#M78617</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-05-23T14:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201902#M78618</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;A href="https://community.cloudera.com/@RAUI"&gt; @RAUI&lt;/A&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please can you give a concrete example of what you intend to do because someone cannot conceptualize  with your explanation &lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 20:56:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201902#M78618</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2018-05-23T20:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201903#M78619</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1271/sheltong.html" nodeid="1271"&gt;@Geoffrey Shelton Okot&lt;/A&gt;, I have few files in hdfs directory. Simply wanted to move files from one hdfs directory to another.&lt;/P&gt;&lt;P&gt;For example: Have file abc.txt in pqr directory wanted to move file to lmn directory.&lt;/P&gt;&lt;P&gt;/apps/pqr/abc.txt move abc.txt to /apps/lmn/abc.txt&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 13:29:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201903#M78619</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-05-24T13:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201904#M78620</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;A href="https://community.hortonworks.com/questions/192335/@RAUI"&gt;@RAUI&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;To copy files between HDFS directories you need  to have the correct permissions i.e  in your example /apps&lt;STRONG&gt;/pqr&lt;/STRONG&gt;/abc.txt move abc.txt to /apps/&lt;STRONG&gt;lmn&lt;/STRONG&gt;/abc.txt.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I assume the  HDFS directory owners as &lt;STRONG&gt;pqr &lt;/STRONG&gt;and l&lt;B&gt;mn&lt;/B&gt; respectively where the former has to have write permission to &lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;/apps/&lt;/STRONG&gt;&lt;B&gt;lmn&lt;/B&gt;/   else you run the copy command ad the HDFS superuser hdfs and then change the file permissions like demonstrated below.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Switch to &lt;B&gt;hfds&lt;/B&gt; users&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;# su - hdfs&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Now  copy the abc.txt  from  source to destination&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;$ hdfs dfs -cp  /apps/pqr/abc.txt    /apps/lmn/&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;check the permissions see the example&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;$ hdfs dfs -ls /apps/lmn
Found 3 items
drwxr-xr-x+  - lmn  hdfs          0 2018-05-24 00:40 /user/lmn/acls
drwxr-xr-x+  - hdfs  hdfs          0 2018-05-24 00:40 /user/lmn/abc.txt
-rw-r--r--   3 lmn  hdfs        642 2018-05-24 08:45 /user/lmn/derby.log&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Change the file permissions recursively for the directory, this should also change the ownership of abc.txt&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;$ hdfs dfs -chown  -R lmn /apps/lmn&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;I hope that helps&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:09:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201904#M78620</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2018-05-24T14:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201905#M78621</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/75181/rahulsmtauti.html" nodeid="75181"&gt;@RAUI&lt;/A&gt; &lt;/P&gt;&lt;P&gt;The answer is &lt;STRONG&gt;no&lt;/STRONG&gt;. Renaming is the way to move files on HDFS: &lt;A href="https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/filesystem/filesystem.html#boolean_renamePath_src_Path_d"&gt;FileSystem.rename()&lt;/A&gt;. Actually, this is exactly what the HDFS shell command "-mv" does as well, you can check it in the &lt;A href="https://github.com/apache/hadoop/blob/4cc0c9b0baa93f5a1c0623eee353874e858a7caa/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java#L38"&gt;source code&lt;/A&gt;. If you think about it, it's pretty logical, since when you move a file on the distributed file system, you don't really move any blocks of the file, you just update the "path" metadata of the file in the NameNode. &lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 14:55:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201905#M78621</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2018-05-24T14:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201906#M78622</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1271/sheltong.html" nodeid="1271"&gt;@Geoffrey Shelton Okot&lt;/A&gt;, Thanks for your time but i was not looking for command line option(knows everyone).&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 16:01:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201906#M78622</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-05-25T16:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201907#M78623</link>
      <description>&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/192335/move-file-from-one-hdfs-directoy-to-another-using.html?childToView=192859#"&gt;@gnovak&lt;/A&gt; Thanks for getting my Question correctly. and the same has been done by me in my scala code. However thought to have others opinion on this.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 16:03:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201907#M78623</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-05-25T16:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201908#M78624</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3369/gnovak.html" nodeid="3369"&gt;@gnovak&lt;/A&gt;, In order to satisfy my need i am doing FileSystem.rename(src,tgt). If target path is not exists will it create?&lt;/P&gt;&lt;P&gt;My understanding is, it will create the target path, however in my case i am able to move file as expected on my local machine and the same code has been deployed on cluster but i am able to move file to desired location. It is not giving me any exception but simply not doing the job.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 21:28:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201908#M78624</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-05-31T21:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201909#M78625</link>
      <description>&lt;P style="margin-left: 40px;"&gt;&lt;A rel="user" href="https://community.cloudera.com/users/75181/rahulsmtauti.html" nodeid="75181"&gt;@RAUI&lt;/A&gt; No, it won't create it, the target directory must exist. However, if the target directory doesn't exist, it won't throw an exception, it will only indicate the error via the return value (as described in the &lt;A href="https://hadoop.apache.org/docs/stable/api/org/apache/hadoop/fs/FileSystem.html#rename%28org.apache.hadoop.fs.Path,%20org.apache.hadoop.fs.Path%29"&gt;documentation&lt;/A&gt;).&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;So 1) you should create the target directory before you call rename() and 2) you should check the return value, like this:&lt;/P&gt;&lt;PRE&gt;fs.mkdirs(new Path("/your/target/path"));
boolean result = fs.rename(
    new Path("/your/source/path/your.file"),
    new Path("/your/target/path/your.file"));
if (!result) {
  ...
}&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 21:48:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201909#M78625</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2018-05-31T21:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201910#M78626</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3369/gnovak.html" nodeid="3369"&gt;@gnovak&lt;/A&gt; thanks for you time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 00:39:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201910#M78626</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-06-01T00:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201911#M78627</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/3369/gnovak.html" nodeid="3369"&gt;@gnovak&lt;/A&gt;, I am still wondering why it has created the directory on my local machine? Kind of wired...&lt;/P&gt;&lt;P&gt;Related to this i have another issue, i am also reading files from hdfs directory using wholeTextFile() my hdfs input directory has text files and sub directories in it. On my local development machine i was able to read the files where wholeTextFile() was not considering sub directories, however whenever i deployed the same code cluster, it started to consider sub directories as well. Do you have any idea on this? Appreciate your help on this   &lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 00:45:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201911#M78627</guid>
      <dc:creator>rahulsmtauti</dc:creator>
      <dc:date>2018-06-01T00:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201912#M78628</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/75181/rahulsmtauti.html" nodeid="75181"&gt;@RAUI&lt;/A&gt; wholeTextFile() is not part of the HDFS API, I'm assuming you're using Spark, with which I'm not too familiar. I suggest you to post another question for this to HCC.</description>
      <pubDate>Fri, 01 Jun 2018 15:27:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201912#M78628</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2018-06-01T15:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Move file from one HDFS directoy to another using scala/java</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201913#M78629</link>
      <description>&lt;P&gt;@RAUI&lt;/P&gt;&lt;P&gt;Yes there is another way of achieving this. You can use the method copy() from the FileUtil class and pass your FileSystem object to it to effectively copy your files from the source HDFS location to the target. As with using rename() you will need to ensure you target directory is created before calling copy. FileUtil.copy() has a signature where you provide a source and destination FS and in this case you would provide the same FS object since you are looking to copy files to a different location on the same HDFS. There is also a boolean option to delete the source file after the copy if that fits your use case.&lt;/P&gt;&lt;P&gt;Here is a link to the FileUtil API: &lt;A href="http://hadoop.apache.org/docs/r2.8.0/api/org/apache/hadoop/fs/FileUtil.html" target="_blank"&gt;http://hadoop.apache.org/docs/r2.8.0/api/org/apache/hadoop/fs/FileUtil.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 23:41:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Move-file-from-one-HDFS-directoy-to-another-using-scala-java/m-p/201913#M78629</guid>
      <dc:creator>formanben4</dc:creator>
      <dc:date>2018-09-04T23:41:34Z</dc:date>
    </item>
  </channel>
</rss>

