[Malvern] Bash script..
Chris Eilbeck
chris at hyperspace.org.uk
Sat Jun 4 22:57:28 BST 2005
On Sat, Jun 04, 2005 at 10:33:02PM +0100, Robin Wilson wrote:
> Hi all,
>
> I haven't yet learnt how to write bash scripts - althought it is on my to
> do list. At the moment though, I need to write a bash script that, when
> given a directory as a command line arguement, will:
> * Rename all files in that directory from filename.JPG to filename.jpg
> (leaving the filename bit the same, just making the JPG in small letters -
> I'm sure this can be done via RegExps)
> * Create a file called 'description' in that directory containing a list of
> all the filenames in that directory then a comma and then the filename
> again... eg:
> filename1.jpg, filename1.jpg
> filename2.jpg, filename2.jpg
>
> Is this possible? and would someone be able to write me a script to do that?
#!/bin/csh
foreach i ( `ls *.JPG | sed s/\.JPG//` )
mv -f $i.JPG $i.jpg
end
echo >description
foreach i ( * )
echo "$i, $i" >>description
end
Dunno how that translates into bash or if it's the most efficient way of
doing the job but it should work on the current directory. Of course, to
recurse a tree you can just use find and the -exec option to call the
script.
Chris
--
Chris Eilbeck
MARS Flight Crew http://www.mars.org.uk/
UKRA #1108 Level 2 UYB
Tripoli UK Member #9527 LSMR
More information about the Malvern
mailing list