renaming (lots of) files in bash

I found this method the other day. Unfortunately, I forget where.

$ for f in `ls -1 | grep string`; do mv $f ${f/string/replace};done

I’d like to find a method of using the bash command `find’, but this is pretty clean, and I don’t yet know how to manipulate the `{}’ in find -exec {} \;

great site for explaining bash variable manipulation.

Share:
  • del.icio.us
  • Reddit
  • Technorati
  • Twitter
  • Facebook
  • Google Bookmarks
  • HackerNews
  • PDF
  • RSS
This entry was posted in programming and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Nate Murray
    Posted January 9, 2009 at 3:08 pm | Permalink

    I also really like Robin Barker’s perl rename script:

    http://tips.webdesign10.com/files/rename.pl.txt

  2. Adam Avilla
    Posted March 5, 2009 at 1:41 pm | Permalink

    you can use find using find instead of ls -1

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">