Reputation: 1838
I have a directory and files looking like this
/Folder/A/12 3ER This.docx
/Folder/A/12 3ER Namespace.docx
/Folder/A/12 QW Blah.docx
/Folder/A/12 QW BlahBlah.docx
/Folder/B/12 3ER Annoying.docx
/Folder/B/12 3ER Were.docx
/Folder/B/12 QW Stack.docx
/Folder/B/12 QW Overlow.docx
...
I want to rename all the files containing 3ER
to _My_
So the directory and files should look like
/Folder/A/12_My_This.docx
/Folder/A/12_My_Namespace.docx
/Folder/A/12 QW Blah.docx
/Folder/A/12 QW BlahBlah.docx
/Folder/B/12_My_Annoying.docx
/Folder/B/12_My_Were.docx
/Folder/B/12 QW Stack.docx
/Folder/B/12 QW Overlow.docx
...
How can I do this with Linux?
Upvotes: 0
Views: 51
Reputation: 295308
find . -name '* 3ER *' -print0 | while IFS= read -r -d '' filename; do
mv -- "$filename" "${filename// 3ER /_My_}"
done
Upvotes: 1