user2080209
user2080209

Reputation: 779

Changing names for all files in subdirectroies

I have a folder with a number of subfolders. Each of the subfolders consists of several files without extension. I need to add extension .cel to each file in subfolders.

How can I do it using bash?

Upvotes: 0

Views: 50

Answers (2)

jaypal singh
jaypal singh

Reputation: 77085

If you have rename then using that with find should do the trick:

find . -type f -exec rename -v 's/$/\.cel/' {} \;

Upvotes: 1

fedorqui
fedorqui

Reputation: 289515

find to the rescue:

find /your/folder -type f -exec mv {} {}.cel \;

Explanation: find obtains all files inside the /your/folder structure. From all the results obtained, it performs the mv command. It makes the file XXX to be moved to XXX.cel, which is another way of renaming it.

Upvotes: 2

Related Questions