Rename all files extension inside folder (including recursive folder).
Thanks for sharing! Is this for a specific operating system? There are many ways to do this on Linux Stack Overflow: How do I rename the extension for a batch of files?
My ruby gem have many advances:
- Cross-platform: Linux, Windows, Mac…that installed Ruby environment
- Customizable old and new file’s extension (passed as params)
- You don’t have to create your own script in multi-device, just install
fec
in one command - Recursive folder supported
- Your turn
Best bonus for me, I get to avoid Windows!
rename
is available for both Mac and Linux and installs just as easily.
Mac install: brew install rename
Linux install: apt-get install rename
The rename
program is not recursive.
If you want to rename recursively you can use find
. Here’s a recursive rename of all html file extensions to txt. This works on both Mac and Linux and you don’t have to install anything.
find . -name '*.html' -exec sh -c 'mv "$0" "${0%.html}.txt"' {} \;
But I’m not trying to compete here. I think it’s awesome that you wrote a gem and it does something useful. I want to encourage more of that. I’ve written many useful gems and many of them don’t ever get discovered by people.
The gem I’ve written most similar to yours is called dfm (duplicate file manager). It is a command line tool that searches all sub-directories and shows you the duplicates in the form of pretty JSON. It finds duplicates of both file name and MD5 checksum.
Every coding project is excellent experience for the developer that does it. Spur of the moment ideas can lead to great “puzzles” to solve which keeps you sharp as a programmer and it’s fun to make things. So yes I’m glad you’ve made the gem.
But it would be also good to acknowledge that there are tools already made for most jobs and sometimes we should be willing to learn the tools rather than re-invent them (except for the experience – you can always do it for the experience).
Bonus; here’s a Windows solution: source
for /r %x in (*.c) do ren "%x" *.cpp