One More Way to Do It

I couldn't resist throwing my hat into this ring. I can imagine an unsophisticated user who might not trust himself to replace one pattern with another, but doesn't want to repeat a long list of mv commands. Here's a simple script () that takes a list of filenames (perhaps provided by wildcards) as input, and prompts the user for a new name for each file:

 -n 
#!/bin/sh # Usage: newname files for x do echo -n "old name is $x, new name is: " read newname mv "$x" "$newname" done

For example:

touch 
% touch junk1 junk2 junk3 % newname junk* old name is junk1, new name is: test1 old name is junk2, new name is: test2 old name is junk3, new name is: test3

This script is so simple, it's not included on the disc. I just thought I'd throw it in to demonstrate that there's more than one way to do it, even if you aren't using Perl ().

- TOR