Sorry for being late to the party (and wildly off topic for a ruby-talk thread). On 8/18/05, Mark Probert <probertm / acm.org> wrote: > Hi .. > > I know that this is kind of heretical, but in a situation like this, I'd > rather use a shell script (I tend to inexpertly use zsh). In this case, > the simple solution is something like: > > $ a=(*.mp3) > $ for f in $a; do > mv $f `basename $f .mp3`.temp > done (BTW, my local zsh doesn't like basename.) This doesn't really answer the initial requirement though, here's an idiomatic bash version ... although the variable mangling's a neat trick, a lot of folks here will probably find it too much like line noise. MP3=`echo *.mp3` TEMP=`echo *.temp` for file in $MP3; do mv $file ${file%.mp3}.temp; done for file in $TEMP; do mv $file ${file%.temp}.mp3; done it's still not safe in terms of overwriting existing files, and there's no question in my mind that the Ruby versions are prettier. > > Pretty easy to read (I'd say more so than the Ruby, IMO) and almost a > one-liner. An easy idiom to remember, no editing required. If you need > to reverse it, then up-arrow and change the lines (or use another > variable, if needed). > > However, if I had to do this as part of a larger project done in Ruby, > then I would have no hesitation to take the Ruby route (and I have done > almost exactly this at times). > > My $0.02 > > Regards, > > > -- > -mark. (probertm at acm dot org) > > > -- thanks, -pate ------------------------- We are often unable to tell people what they need to know, because they want to know something else, and would therefore only misunderstand what we said - the Raven (George MacDonald, Lilith)