Thursday, February 26, 2009

renaming files on Mac OS X with ruby

So, for example you have bunch of ".htm" files that you want to rename to ".html"

You need to open your "cd" to the directory where you files are and run this command:
ruby -e "Dir.glob('*.htm').each{|file| File.rename(file,file.gsub('.htm', '.html'))}"

If you want it to work for a current and all recursive directories you need to make a simple change:
ruby -e "Dir.glob('**/*.htm').each{|file| File.rename(file,file.gsub('.htm', '.html'))}"

1 comment:

sailerkafka said...

The Best Real Money Casinos | Complete list of casinos in 2021
1. Ignition Casino – $400 Bonus + 250 free spins + 20 free spins. 2. Café 먹튀검증업체 순위 Casino – $100 한게임 포커 apk Bonus + 20 한게임바카라 free spins + 20 다 파벳 모바일 free spins. 3. Super Slots – $1,000 Bonus 실시간 바카라 + 20