recursively change file name extensions

find . -type f -name \*.c | while read f; do mv $f "`basename $f .c`".C; done
or, for a single directory: for f in *.c; do mv $f "`basename $f .c`".C; done
Sample Output
$ ls
kk1.c  kk2.c  kk3.c  kk4.c
$ find . -type f -name \*.c | while read f; do mv $f "`basename $f .c`".C; done
$ ls
kk1.C  kk2.C  kk3.C  kk4.C

By: berta
2009-02-17 09:30:43

What Others Think

This rather inelegantly borked my files on a mac. This worked, though: find . -type f -name *.c | sed 's/\(.*\)\.c/mv "\1.c" "\1.C"/' | sh
bingaman · 683 weeks and 1 day ago
On your first trip to LA kitchen remodeling santa barbara
tillyracker · 60 weeks and 1 day ago
I think you must take help from the experts in this field. I can only help if you wanna know how long does it take to build a website and I will give you the best help regarding this. For now, you must visit the website.
nicolasconner · 50 weeks and 1 day ago
seofox · 38 weeks and 5 days ago
Most BCMs need to be programmed by the remanufacturer or a shop equipped with the proper tools. If the replacement BCM needs programming, it must be programmed with the latest operating software and vehicle calibrations.Any control module needs to be and flashed or reprogrammed to link to the sensors and monitors of an individual vehicle in order for them to work correctly. This needs to be completed by a dealer or some automotive specialists, as they control security codes to reprogram these systems.
ReaderWriter12 · 11 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: