O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



renaming files
Use this script to rename all files with common extension.

Contributed by:
Dawa Lama
[02/06/04 | Discuss (2) | Link to this hack]

Let's say you have a directory containing files with extension .shtml. How would you go about renaming those to .html or .oldshtml

Here is a small script you can use to do that.

for i in `ls *.shtml` ; do mv $i ${i/shtml/html}; done

In general, do this for i in 'ls *.<oldextension>'; do mv $i ${i/<oldextension>/<newextension>}; done

Peace :-)


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.