MLUG: Re: [MLUG] Renaming a bunch of files
Re: [MLUG] Renaming a bunch of files
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On Thu, 1 Mar 2001, Michael wrote:

> Why not just make a script to rename a single file and just pass all the
> files through find . -iname "*.mp3" --exec myrename {} \;??

Oh.  Something like that is a better idea.  We have to be careful of how
the filenames are fed into the script.  The spaces can do weird things.
Here's a script called 'myrename' that might do what you want:


--------------------------------------------------------------------------
#!/usr/bin/tcsh -f

set newname = `echo "$1" | awk -F: '{print $NF}'`
mv "$1" "$newname"
end
--------------------------------------------------------------------------


It has to take an actual filename as input -- no wildcard characters!  It
also always puts the renamed file in the default directory, even if the
file was originally elsewhere.

I think it works, but I'll bet someone can improve on it.

Mike

--
To manage your subscription, go to http://mlug.missouri.edu/members/edit.php

Archives are available at http://mlug.missouri.edu/list-archives/