-1

I have a directory called Dual_Loop_PLL. Inside that I have 2 subdirectories: agent and test. Inside agent I have a directory called dl_pll_agent, and inside dl_pll_agent I have dl_pll_agent2. I want to rename dl_pll_agent and dl_pll_agent2 to dual_loop_pll_agent and dual_loop_pll_agent2 respectively.

I have used following command.

echo -e "Enter directory name you want to replace : "
read d1
echo "Enter directory name with which you want to replace : "
read d2
find  -type d -exec rename $d1 $d2 * {} +

but I am getting following error

rename: renaming ./Dual_Loop_PLL/agents/dl_pll_agent/dl_pll_agent2 to ./Dual_Loop_PLL/agents/dual_loop_pll_agent/dl_pll_agent2 failed: No such file or directory
  • What rename are you using: in man rename who is the author? What is the usage line of rename --help? (show by editing question) – ctrl-alt-delor Mar 22 at 9:32
  • agents or agent? – ctrl-alt-delor Mar 22 at 9:33
  • What is the output of ls -l ./Dual_Loop_PLL/agents ./Dual_Loop_PLL/agents/dual_loop_pll_agent – ctrl-alt-delor Mar 22 at 9:34
0

What is the output of ls -l ./Dual_Loop_PLL/agents ./Dual_Loop_PLL/agents/dual_loop_pll_agent?

If you will answer the above question then you will have the answer to your question.

Also read the manual for rename, and the section of the bash manual on quoting: Always quote your variables e.g. "$d1".

And I am not sure what you are doing with rename, you pass it: the evaluation of $d1 and $d2, a list of all the files in the current directory, and a list of file found by find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.