How to rename several files in different locations

Forum rules
Before you post please read how to get help
Post Reply
MechWright
Level 1
Level 1
Posts: 19
Joined: Thu Dec 27, 2018 11:30 am

How to rename several files in different locations

Post by MechWright »

Hi guys&gals,

I need to rename several files in different locations, for example /folder1/Test -> /folder1/Test.txt , /folder2/Test -> /folder2/Test.txt and so on, that is
the names are standard but the folders are not. The files to be renamed can be easily found using my favourite bash command FIND, but then what?

Code: Select all

find . -name "Test" -exec mv {} ??

rene
Level 14
Level 14
Posts: 5284
Joined: Sun Mar 27, 2016 6:58 pm

Re: How to rename several files in different locations

Post by rene »

For example, find -name Test -exec mv {} {}.txt \;

Post Reply

Return to “Scripts & Bash”