Posted By

ches on 09/07/07


Tagged

Bash script sed awk rename


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

rhockens
moonbather
IanLewis
jmontano
romulousprime


Batch File Rename with awk and sed


 / Published in: Bash
 

URL: http://www.macosxhints.com/article.php?story=20010509130450691

Leave off the final pipe to /bin/sh to do a 'dry run'

  1. ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: IanLewis on January 29, 2009

You can also do other commands to select files to rename. Like

find . -name "foo*.jpg" | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh

You need to login to post a comment.