How to rename several files in different locations

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
MechWright
Level 1
Level 1
Posts: 44
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 {} ??
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
rene
Level 20
Level 20
Posts: 12212
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 \;
Locked

Return to “Scripts & Bash”