2

ive recently been trying to change the names around in my project and have been having some trouble getting the task done properly.

my problem is when I try to use

find . -type f -print0 | xargs -0 sed -i 's/volix/sergio/g' find . -type f -print0 | xargs -0 sed -i 's/Volix/Sergio/g' find . -type f -print0 | xargs -0 sed -i 's/VOLIX/SERGIO/g' find . -type f -print0 | xargs -0 sed -i 's/VLX/SRG/g'

this will find and replace all the names within the files im trying to change, but it leaves the name of the folders still the same as what they before the name changes.

EDIT: I would like to replace all occurrences of "volix" to "sergio" without disturbing the rest of the file name so I would like to replace like this

  • volix-res.rc
  • volix.qrc
  • volix-tx.cpp
  • volix_logo_horizontal.png
  • volix_logo_horizontal2x.png
  • unit_tmvolix.png
  • unit_tvolix.png

to -

  • sergio-res.rc
  • sergio.qrc
  • sergio-tx.cpp
  • sergio_logo_horizontal.png
  • sergio_logo_horizontal2x.png
  • unit_tmsergio.png
  • unit_tsergio.png

and many more files with the name "volix"in it, im wondering how I can change all of these at once instead of manually renaming one by one?

4
  • well I just have one main folder named "Sergio" and inside this folder ive got a bunch of sub-directories and files and pictures that all need to be renamed from "volix" to "sergio", I just tried to use command you gave me and it returned error - find: missing argument to "-exec" Oct 20, 2018 at 4:27
  • 1
    My mistake. You need this: find -type d -name current_name -exec mv {} desired_name \; Oct 20, 2018 at 5:09
  • thankyou very much worked perfectly =)!! Oct 20, 2018 at 5:20
  • You are welcome. I'll post it as an answer. Oct 20, 2018 at 5:24

2 Answers 2

1

find . type -f only finds files.

What you need is:

find -type d -name current_name -exec mv {} desired_name \; 

That will find directories recursively and rename them to what you desire.

0

Try this:

find . -type f -print0 |
  parallel -0 mv {} '{= s/volix/sergio/g; s/Volix/Sergio/g; s/VOLIX/SERGIO/g; s/VLX/SRG/g =}'

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.