Re: how to rename multiple files

2003-01-07 Thread Rogier Wolff
On Sat, Jan 04, 2003 at 09:51:21PM -0500, Fraser Campbell wrote: > On January 4, 2003 09:20 pm, the fabulous Gerald V. Livingston II wrote: > > > 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

Re: how to rename multiple files

2003-01-05 Thread Bob Proulx
Colin Watson <[EMAIL PROTECTED]> [2003-01-05 13:46:32 +]: > > find . -maxdepth 1 -name '*.jpg' -print | head -n 1 | grep -q . > > -q already stops at the first match, so there is no need to do this. [I had to check. ;-) The option -q sets done_on_match and the code quits at the first chanc

Re: how to rename multiple files

2003-01-05 Thread Bill Moseley
On Sun, 5 Jan 2003, Mark Zimmerman wrote: > Yes, but that's not all. Setting MATCH=*.jpg does not seem to trigger > the globbing function in bash, to my surprise. The following does > work, though: > > shopt -s nullglob > MATCH=$(printf %s *.jpg) > if [ -n "$MATCH" ]; then SOME=TRUE; else SOME=FA

Re: how to rename multiple files

2003-01-05 Thread Mark Zimmerman
On Sun, Jan 05, 2003 at 04:13:49AM +, Colin Watson wrote: > On Sat, Jan 04, 2003 at 06:58:18PM -0700, Mark Zimmerman wrote: > > shopt -s nullglob > > SOME=FALSE > > MATCH=*.jpg > > for f in $MATCH; do SOME=TRUE; break; done > > > > I tried [ -z $MATCH ] also but it always fails even though ech

Re: how to rename multiple files

2003-01-05 Thread Colin Watson
On Sat, Jan 04, 2003 at 09:55:42PM -0700, Bob Proulx wrote: > Colin Watson <[EMAIL PROTECTED]> [2003-01-05 04:04:19 +]: > > > And I've bumped into this. How *DOES* one test for the existence of > > > ANY file with a given extension without getting a "too many arguments" > > > error when there a

Re: how to rename multiple files

2003-01-04 Thread Bob Proulx
Colin Watson <[EMAIL PROTECTED]> [2003-01-05 04:04:19 +]: > > And I've bumped into this. How *DOES* one test for the existence of > > ANY file with a given extension without getting a "too many arguments" > > error when there are multiple files? > > How about: > > find . -maxdepth 1 -name '

Re: how to rename multiple files

2003-01-04 Thread Gerald V. Livingston II
Colin Watson said: >> 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 > > In general it's better to avoid putting backticks in the middle of

Re: how to rename multiple files

2003-01-04 Thread Bob Proulx
Fraser Campbell <[EMAIL PROTECTED]> [2003-01-04 21:51:21 -0500]: > On January 4, 2003 09:20 pm, the fabulous Gerald V. Livingston II wrote: > > > 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

Re: how to rename multiple files

2003-01-04 Thread Colin Watson
On Sat, Jan 04, 2003 at 08:20:18PM -0600, Gerald V. Livingston II wrote: > 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. > > > >

Re: how to rename multiple files

2003-01-04 Thread Colin Watson
On Sat, Jan 04, 2003 at 06:58:18PM -0700, Mark Zimmerman wrote: > shopt -s nullglob > SOME=FALSE > MATCH=*.jpg > for f in $MATCH; do SOME=TRUE; break; done > > I tried [ -z $MATCH ] also but it always fails even though echo $MATCH > prints an empty string. You probably need to double-quote "$MATC

Re: how to rename multiple files

2003-01-04 Thread Colin Watson
On Sat, Jan 04, 2003 at 07:00:03PM -0600, Gerald V. Livingston II wrote: > Colin Watson said: > > On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: > >> if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; > >> done fi > > > > That -e test looks dreadful ... surely it'll usua

Re: how to rename multiple files

2003-01-04 Thread Fraser Campbell
On January 4, 2003 09:20 pm, the fabulous Gerald V. Livingston II wrote: > 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 If there were

Re: how to rename multiple files

2003-01-04 Thread Raja R Harinath
Hi, "Gerald V. Livingston II" <[EMAIL PROTECTED]> writes: > Colin Watson said: > >> On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: >>> if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; >>> done fi >> >> That -e test looks dreadful ... surely it'll usually expand to lo

Re: how to rename multiple files

2003-01-04 Thread Gerald V. Livingston II
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 no

Re: how to rename multiple files

2003-01-04 Thread Michael Naumann
05.01.2003 02:00:03, "Gerald V. Livingston II" <[EMAIL PROTECTED]> wrote: >I want "TRUE" if there is one or more zzz.jpg files in a directory, >"FALSE" if there are zero of them. One solution might be: ls | grep -q '\.jpg$' Cheers, Michael -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with

Re: how to rename multiple files

2003-01-04 Thread Mark Zimmerman
On Sat, Jan 04, 2003 at 07:00:03PM -0600, Gerald V. Livingston II wrote: > Colin Watson said: > > > On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: > >> if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; > >> done fi > > > > That -e test looks dreadful ... surely it'll u

Re: how to rename multiple files

2003-01-04 Thread Jamin W. Collins
On Sat, Jan 04, 2003 at 07:00:03PM -0600, Gerald V. Livingston II wrote: > And I've bumped into this. How *DOES* one test for the existence of > ANY file with a given extension without getting a "too many arguments" > error when there are multiple files? > > I want "TRUE" if there is one or more

Re: how to rename multiple files

2003-01-04 Thread Gerald V. Livingston II
Colin Watson said: > On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: >> if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; >> done fi > > That -e test looks dreadful ... surely it'll usually expand to lots of > arguments which will confuse [, or perhaps to an empty strin

Re: how to rename multiple files

2002-12-10 Thread Colin Watson
On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: > if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; done fi That -e test looks dreadful ... surely it'll usually expand to lots of arguments which will confuse [, or perhaps to an empty string (nullglob) which will also co

Re: how to rename multiple files

2002-12-10 Thread Osamu Aoki
On Tue, Dec 10, 2002 at 10:11:20AM -0500, Rick Pasotto wrote: > On Mon, Dec 09, 2002 at 11:33:03PM -0800, Osamu Aoki wrote: > > On Mon, Dec 09, 2002 at 10:02:25PM -0600, Shyamal Prasad wrote: > > > "drew" == drew cohan <[EMAIL PROTECTED]> writes: > > > > > > drew> How do I rename all files

Re: how to rename multiple files

2002-12-10 Thread Rick Pasotto
On Mon, Dec 09, 2002 at 11:33:03PM -0800, Osamu Aoki wrote: > On Mon, Dec 09, 2002 at 10:02:25PM -0600, Shyamal Prasad wrote: > > "drew" == drew cohan <[EMAIL PROTECTED]> writes: > > > > drew> How do I rename all files in a directory matching the > > drew> pattern *.JPG to *.jpg in a b

Re: how to rename multiple files

2002-12-10 Thread Colin Watson
On Mon, Dec 09, 2002 at 11:33:03PM -0800, Osamu Aoki wrote: > Simplest alternative without sub-shell nor special command: > > for i in *.JPG > do > mv $i ${i%\.JPG}.jpg > done > > It works with any reasonable shell ash/bash/dash/... and uses only mv > command. I like the various clever shell

Re: how to rename multiple files

2002-12-10 Thread Jason Majors
On Mon, Dec 09, 2002 at 11:33:03PM -0800, Osamu Aoki scribbled... > On Mon, Dec 09, 2002 at 10:02:25PM -0600, Shyamal Prasad wrote: > > "drew" == drew cohan <[EMAIL PROTECTED]> writes: > > > > drew> How do I rename all files in a directory matching the > > drew> pattern *.JPG to *.jpg

Re: how to rename multiple files

2002-12-09 Thread Osamu Aoki
On Mon, Dec 09, 2002 at 10:02:25PM -0600, Shyamal Prasad wrote: > "drew" == drew cohan <[EMAIL PROTECTED]> writes: > > drew> How do I rename all files in a directory matching the > drew> pattern *.JPG to *.jpg in a bash shell script? Thanks to > drew> you guys I can check for the

Re: how to rename multiple files

2002-12-09 Thread Shyamal Prasad
"drew" == drew cohan <[EMAIL PROTECTED]> writes: drew> How do I rename all files in a directory matching the drew> pattern *.JPG to *.jpg in a bash shell script? Thanks to drew> you guys I can check for the existence of jpgs in a drew> directory, but can't seem get 'mv' to ren

Re: how to rename multiple files

2002-12-09 Thread Colin Watson
On Mon, Dec 09, 2002 at 04:29:37PM -0500, drew cohan wrote: > On Mon, Dec 09, 2002 at 03:03:10PM -0500, drew cohan wrote: > > How do I rename all files in a directory matching the pattern *.JPG to > > *.jpg in a bash shell script? Thanks to you guys I can check for the > > existence of jpgs in a d

Re: how to rename multiple files

2002-12-09 Thread Craig Dickson
drew cohan wrote: > Thanks, once again, you guys are great. One quick question about this > one: > > $ rename 's/\.JPG$/.jpg/' *.JPG > > Shouldn't I literalize the second period like > > $ rename 's/\.JPG$/\.jpg/' *.JPG > > or doesn't that make a difference? The replacement text is not a

Re: how to rename multiple files

2002-12-09 Thread martin f krafft
also sprach drew cohan <[EMAIL PROTECTED]> [2002.12.09.2229 +0100]: > Thanks, once again, you guys are great. One quick question about this > one: > > $ rename 's/\.JPG$/.jpg/' *.JPG > > Shouldn't I literalize the second period like > > $ rename 's/\.JPG$/\.jpg/' *.JPG > > or doesn't that

RE: how to rename multiple files

2002-12-09 Thread drew cohan
On Mon, Dec 09, 2002 at 03:03:10PM -0500, drew cohan wrote: > How do I rename all files in a directory matching the pattern *.JPG to > *.jpg in a bash shell script? Thanks to you guys I can check for the > existence of jpgs in a directory, but can't seem get 'mv' to rename them > for me (always co

Re: how to rename multiple files

2002-12-09 Thread Andrei Smirnov
On Mon, Dec 09, 2002 at 03:03:10PM -0500, drew cohan wrote: > How do I rename all files in a directory matching the pattern *.JPG to > *.jpg in a bash shell script? Thanks to you guys I can check for the > existence of jpgs in a directory, but can't seem get 'mv' to rename them > for me (always co

Re: how to rename multiple files

2002-12-09 Thread Oliver Fuchs
On Mon, 09 Dec 2002, drew cohan wrote: > How do I rename all files in a directory matching the pattern > *.JPG to *.jpg in a bash shell script? Thanks to you guys I can > check for the existence of jpgs in a directory, but can't seem get > 'mv' to rename them for me (always complains that the las

Re: how to rename multiple files

2002-12-09 Thread Vinai Kopp
> drew cohan wrote: > > > How do I rename all files in a directory matching the pattern *.JPG to > > *.jpg in a bash shell script? Thanks to you guys I can check for the > > existence of jpgs in a directory, but can't seem get 'mv' to rename them > > for me (always complains that the last argumen

Re: how to rename multiple files

2002-12-09 Thread Colin Watson
On Mon, Dec 09, 2002 at 03:03:10PM -0500, drew cohan wrote: > How do I rename all files in a directory matching the pattern *.JPG to > *.jpg in a bash shell script? Thanks to you guys I can check for the > existence of jpgs in a directory, but can't seem get 'mv' to rename them > for me (always co

Re: how to rename multiple files

2002-12-09 Thread Brian P. Flaherty
There are also mmv, mcp, mad, and mln. The syntax takes a little getting used to, but once you get a feel for it, this is a nice set of programs. I think you can apt-get mmv. Here's an example I used yesterday. It takes a bunch of files starting with week, then a 0 or a 1, then a single charact

Re: how to rename multiple files

2002-12-09 Thread Craig Dickson
drew cohan wrote: > How do I rename all files in a directory matching the pattern *.JPG to > *.jpg in a bash shell script? Thanks to you guys I can check for the > existence of jpgs in a directory, but can't seem get 'mv' to rename them > for me (always complains that the last argument must be a