To: x4u@lists.themacintoshguy.com (Mac OS X for Users)
Date: Wed, 25 Apr 2001 17:59:48 -0700
From: Deirdre Saoirse Moen deirdre@deirdre.net
Subject: Re: [X4U] quick command-line question

At 2:47 PM -0400 4/25/01, uoxton wrote:
>what's wrong with this?
>
>mv *.jpg *_some_string.jpg

I figured I'd give another approach, in part because you can prototype the
results before committing to them. Say you want to change the "foo" in each
filename to a "bar":

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

Then you get the output. Look right? When it is, pipe it through a shell.

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

While there's (as you've figured) a bunch of ways of doing this task, few
offer the ability to prototype like this.

--
_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."