user2251284
user2251284

Reputation: 417

Rename multiple files named the same thing throughout a project

Linux/Bash, I have a directory with many directories inside of it. the inside directories occasionally have the same name of FOO. I want to rename every occurrence of FOO to BAR.

Alternatively, just make git think BAR every time it ever heard FOO. I want the files to stay in their place.

Also, not sure a basic rebase will work to scrub FOO out, due to FOOs being introduced many times.

I have tried:

#!/bin/ksh
for oldfile in $(find . -name FOO*)
do
   newfile="BAR"
   mv "$oldfile" "$newfile"
done

edit: have also tried: find . -name foo -type d -execdir mv {} bar \;

but i get

find: `./w08/foo': No such file or directory

Upvotes: 1

Views: 42

Answers (1)

anubhava
anubhava

Reputation: 785276

You can use find with -execdir:

find . -name "FOO*" -execdir mv '{}' bar \;

Upvotes: 2

Related Questions