Re: rename shell command

2004-01-26 Thread jan . muenther
Two things: 

First of all, Mac OS X is not BSD. It has a BSD-derived userland, but a
microkernel (Darwin) and is generally not quite the same. 
In any way, you should look into mv and learn basic shell scripting. 

Regards, J.


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: rename shell command

2004-01-26 Thread Matthew Seaman
On Mon, Jan 26, 2004 at 12:03:23PM +0100, Andrew Kotsopoulos wrote:

 I'm looking for the rename shell command for the macosx version of 
 bsd.  In redhat and possibly other linux distributions the command 
 renames files and supports wildcards and multiple file conversions, as 
 you most likely know.  To be more precise here is the man page:

Interesting.  Sounds like it would make a good port.  However, check
out the misc/mmv port -- it sounds like it has very similar
functionality to the rename command you've been using.

Anyhow, it's a pretty trivial script to write.  Here's a perl verion I
cooked up in a few minutes -- use with care as it has only had minimal
testing.  Note too that the 'from' expression is actually a perl
regular expression, rather than a literal match.

#!/usr/bin/perl -w

$0 =~ [EMAIL PROTECTED]/@@;

if (@ARGV  3) {
die E_O_USAGE;
$0: Usage:
$0 from to file...
E_O_USAGE
}  

$::from = shift @ARGV;
$::to   = shift @ARGV;

foreach my $file (@ARGV) {
my $nfile;

($nfile = $file) =~ s/$::from/$::to/;

if ($nfile ne $file) {
rename $file, $nfile
or die $0: Couldn't rename \$file\ to \$nfile\ -- $!\n;
}
}
#
# That's All Folks!
#

Cheers,

Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.   26 The Paddocks
  Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614  Bucks., SL7 1TH UK


pgp0.pgp
Description: PGP signature


Re: rename shell command

2004-01-26 Thread parv
in message [EMAIL PROTECTED],
wrote Andrew Kotsopoulos thusly...

 I'm looking for the rename shell command for the macosx version
 of bsd.  In redhat and possibly other linux distributions the
 command renames files and supports wildcards and multiple file
 conversions, as you most likely know.

  http://groups.google.com/groups?th=b45310c8ba0519a
  http://groups.google.com/groups?q=rename+file+group%3Acomp.unix.*


  - Parv

-- 

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: rename shell command

2004-01-26 Thread Jonathan T. Sage

I'm looking for the rename shell command for the macosx version
of bsd.  In redhat and possibly other linux distributions the
command renames files and supports wildcards and multiple file
conversions, as you most likely know.

Couldn't resist a bit of a plug.  I have something that will do this and 
much much more, written in perl.  It's called PerlRename, and it is 
availible here:  http://wfbsd.jtsage.com

~j

--
Yesterday upon the stair I saw a man
who wasn't there, he wasn't there
again today, oh how i wish he'd go away
Jonathan T. Sage
Lighting / Set Designer
Professional Web Design
[HTTP://theatre.msu.edu]
[EMAIL PROTECTED]
[See Headers for Contact Info]


pgp0.pgp
Description: PGP signature


Re: rename shell command

2004-01-26 Thread Cordula's Web
 I'm looking for the rename shell command for the macosx version of 
 bsd.  In redhat and possibly other linux distributions the command 
 renames files and supports wildcards and multiple file conversions, as 
 you most likely know.  To be more precise here is the man page:

Here's a script in perl. Use like this:

  ### Append .bak to all *.c files
  $ rename '$_ .= .bak' *.c

  ### Remove .bak from all *.c.bak files
  $ rename 's/\.bak$//' *.c.bak

  ### Convert to lowercase, but not for Makefile
  $ rename 'tr/A-Z/a-z/ unless /^Makefile/' *

#!/usr/bin/perl -w
# rename -- Larry's filename fixer

$op = shift or die Usage: rename expr [files]\n;
chomp(@ARGV = STDIN) unless @ARGV;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}

-- 
Cordula's Web. http://www.cordula.ws/

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


History of Rename, as I Know It (Re: rename shell command)

2004-01-26 Thread parv
in message [EMAIL PROTECTED], wrote Andrew Kotsopoulos
thusly...

 parv wrote:

   http://groups.google.com/groups?th=b45310c8ba0519a

 Thanks for the tips to all that responded to me - I've seen quite
 a few suggestions for scripts of various kinds.

Did you send personalized email to everybody or you forgot to copy
-questions?


 what I really want to know is what's the offical story with
 rename?  On my redhat 8 dist. it's a binary and lives in
 /usr/bin.  I believe it was part of the fileutils or coreutils
 package and they are supposed to be GNU packages (or not?)

The original rename was, as i know it, from Larry wall, creator of
Perl.  From http://groups.google.com/groups?selm=33089%40adm.brl.mil
...

If you have the perl language installed, you may find this
rename script by Larry Wall very useful.  It can be used to
accomplish a wide variety of filename changes.

#!/usr/bin/perl
#
# rename script examples from lwall:
#   rename 's/\.orig$//' *.orig
#   rename 'y/A-Z/a-z/ unless /^Make/' *
#   rename '$_ .= .bad' *.f
#   rename 'print $_: ; s/foo/bar/ if stdin =~ /^y/i' *

$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}


...I heard/read once about it when i was starting with Perl more than
5 years ago.  The original rename was not part of the standard Perl
distribution; it was included by distributor(s) of Linux...

  http://www.oclug.on.ca/pipermail/oclug/2002-March/018696.html


...which mentions your RedHat too, besides mentioning that rename
appeared in Programming Perl, first edition.


It seems to appear  had appeared under similar name for the same
purpose.  Sometimes the program is wholly independent, else it is
enhancement of the original.  Mother necessity is of invention, or
something like that.

I also noticed some blurb in comp.* newsgroup that involved C and
rename.  Oh wait ...

  #  man -aw rename

...ok, there is also rename(2), a C library function, in libc, that
conform[s] to ISO/IEC 9945-1:1996 (``POSIX.1'').


  - Parv

-- 

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]