Re: how to rename multiple files
Jamin W. Collins said:
> On Sat, Jan 04, 2003 at 07:00:03PM -0600, Gerald V. Livingston II
> wrote:
>
>> I want "TRUE" if there is one or more zzz.jpg files in a directory,
>> "FALSE" if there are zero of them.
>
> Assuming you don't want the names of the files, just whether they are
> there or not:
>
> ls *.ext 2> /dev/null | wc -l
>
> If there are no files you get a 0, if there are you get the number of
> them. Thus a non-zero result means TRUE and a zero result means
> FALSE.
>
> --
> Jamin W. Collins
Thank you. Took a couple of tries to get the syntax correct but I
ended up with this:
if [ `ls *.jpg 2>/dev/null|wc -l` -gt 0 ]
then for i in *.jpg; do mmv "$i" `date +%s`-$a.jpg; a=a+1; done
fi
Works beautifully. (I ripped out the directory names to prevent
wrapping as that stuff is all buried deep in /home/username/.....)
G
--
Gerald
http://www.phorce1.com
http://www.buskatiers.org
Reply to: