On Tue, 2003-06-17 at 22:48, James Ogley wrote:
Hi,
Evening,
Hope someone can help me with this...
Will give it a try. :)
I've got a directory with about 1000 or so files named with this convention:
filename.SNG.txt
(don't ask - long story...)
Now, filename is a random sequence of between 5 and eight numeric characters.
But it _always_ follows the convention of <something>.SNG.txt ?
My question is this:
Does anyone know of a way in bash script to rename all the files of the above format to filename.txt?
Easy. for file in *.SNG.txt do newfile=${file%%.*} mv $file $newfile.txt done
To throw (potentially) a spanner in the works, the files that need to be renamed aren't the only files in the directory.
As long as no files you want to keep as they are are called <something>.SNG.txt you should be alright.
Any help will be gratefully accepted.
Hope this helped.
--
Anders Karlsson