[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Renaming files



On Sun, 5 Jan 2003 21:57:45 -0600
will trillich <will@serensoft.com> wrote:

> On Sun, Jan 05, 2003 at 01:19:59AM -0600, Gerald V. Livingston II
> wrote:
> > The script:cat ~/bin/names
> > 
> > #!/bin/bash
> > 
> > typeset -i a=1
> > 
> how about
> 
> 	ls /t/*.jpg /t/*.JPG /t/*.jpeg 2>/dev/null | wc -l
> or
> 	ls /t/*.{jpg,jpeg,JPG,JPEG} 2>/dev/null | wc -l
> 
> hmm? only one test, all done.
> 
> 
> same here:
> 
> 	ls /t/*.gif /t/*.GIF /t/*.GIFF 2>/dev/null | wc -l
> 
> or even
> 
> 	ls /t/*.{gif,GIF,giff,GIFF} 2>/dev/null | wc -l
> 
> 
> 	ls /t/*.{bmp,BMP} 2>/dev/null | wc -l
> 
> > if [ `ls /t/*.bmp 2>/dev/null|wc -l` -gt 0 ]
> >   then for i in /t/*.bmp;
> >    do convert "$i" `basename "$i" .bmp`.jpg; rm -f "$i"; done
> > fi
> 
> nicely done.
> 
> > if [ `ls /t/*.jpg 2>/dev/null|wc -l` -gt 0 ]
> >  then for i in /t/*.jpg;
> >   do echo "http://host.com/images/$i"; >>/t/links; done
> > fi
> > 
> > if [ `ls /t/*.gif 2>/dev/null|wc -l` -gt 0 ]
> >  then for i in /t/*.gif;
> >   do echo "http://host.com/images/$i"; >>/t/links; done
> > fi
> 
> how about
> 
> 	for i in /t/*.{gif,jpg};
> 		do echo "http://host.com/images/$i"; >> /t/links ; done
> 
> get all the gif and jpg in one swoop.

I guess you noticed I'm not real good about command compression. I
*REALLY* need to get the O'Reilley bash book to have on hand for stuff
like this. I just have to work with it so seldom. I'll make the changes
above then start on the problems listed below. Probably have to take it
back to the procmail list to see if there's a better way to determine
the contents of a MIME message. 

Need to security clean the script and my .procmailrc and drop them on a
web server since they are growing with each new problem. 

The problem I'm having now that I'm testing it with other file types and
various maiers sending the attachments is the way "un-named"
attachments are dealt with. They mostly (even images) seem to end up
coming through as "application/octet-stream" with no name in the mime.
So I end up with a bunch od random file names. Guess I'm going to have
to play with running 'file' over each item in the temp directory <sigh>

G

-- 
Configure your Email to send TEXT ONLY -- See the following page:
http://expita.com/nomime.html

gvl2 (Gerald)
AirBall the Rolling Basket Case (1969 Standard Beetle)
LifeSaver (1974 Bay Window Bus)
http://www.phorce1.com



Reply to: