0

I want to copy some 1500 files from one folder on cluster to another folder but meanwhile i want to append a suffix or prefix to the name of file. If this is done for just a one file then we could simply do

hdfs dfs -cp /sourcePath/fileName /destinationPath/fileName-new

but as there are 1500 files i want to do this in something like

hdfs dfs -cp /sourcePath/* /destinationPath/*-new

But I can't use * as file name placeholder. However if there was some way to get all the file names of a folder present on cluster we can iterate over then and use command as in

nohup bash -c 'for i in AllFileNames; do hdfs dfs -cp /sourceDir/$i /destinationDir/$i-new do ; done' &

So what should be the way out from this problem ?

  • Does this answer your question? [How to list only the file names in HDFS](https://stackoverflow.com/questions/21569172/how-to-list-only-the-file-names-in-hdfs) – Leonid Vasilev Jul 06 '21 at 20:33
  • No, it will only list the file names but we can't simply put 1500 file names in a command. I tried with that and it takes more than 5 minutes to just copy the command from notepad and and that too crashes the terminal – Kuldeep J Jul 14 '21 at 09:30

0 Answers0