Is there a simple command for hadoop that can change the name of a file (in the HDFS) from its old name to a new name?
Use fs. rename() by passing source and destination paths to rename a file. Note that in the above example we also check if the file exists using fs. exists(path) method.
The answer is no. Renaming is the way to move files on HDFS: FileSystem. rename(). Actually, this is exactly what the HDFS shell command "-mv" does as well, you can check it in the source code.
HDFS has the notion of Protected Directories, which are declared in the option fs. protected. directories. Any attempt to delete or rename such a directory or a parent thereof raises an AccessControlException.
Use the following :
hadoop fs -mv oldname newname
The above ones works pretty well. Also this version works all the time for me.
hdfs dfs -mv oldname.txt newname.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With