FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 08-05-2008, 04:20 PM
Rashkae
 
Default Where art thou 'rename'

In the days of yore, I often used a neat little program called rename to
do bulk file renames.

I've just noticed in my Gutsy system that rename has since been replace
with a new perl program, which though more powerful, has dramatically
different syntax.

Here's a man page I found of the rename I know and love:

http://costard.lbl.gov/cgi-bin/man/man2html?rename+1

anyone know where I can find this program?

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 06:26 PM
NoOp
 
Default Where art thou 'rename'

On 08/05/2008 09:20 AM, Rashkae wrote:
> In the days of yore, I often used a neat little program called rename to
> do bulk file renames.
>
> I've just noticed in my Gutsy system that rename has since been replace
> with a new perl program, which though more powerful, has dramatically
> different syntax.
>
> Here's a man page I found of the rename I know and love:
>
> http://costard.lbl.gov/cgi-bin/man/man2html?rename+1
>
> anyone know where I can find this program?
>

Looks like the Ubuntu version is actually 'prename':
http://bbs.archlinux.org/viewtopic.php?pid=338101


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 06:41 PM
Romain Kang
 
Default Where art thou 'rename'

Here's something posted to USENET ca. 1991. I've been carrying around
my own copy ever since:

#! /usr/local/bin/perl
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 06:55 PM
Rashkae
 
Default Where art thou 'rename'

NoOp wrote:
> On 08/05/2008 09:20 AM, Rashkae wrote:
>> In the days of yore, I often used a neat little program called rename to
>> do bulk file renames.
>>
>> I've just noticed in my Gutsy system that rename has since been replace
>> with a new perl program, which though more powerful, has dramatically
>> different syntax.
>>
>> Here's a man page I found of the rename I know and love:
>>
>> http://costard.lbl.gov/cgi-bin/man/man2html?rename+1
>>
>> anyone know where I can find this program?
>>
>
> Looks like the Ubuntu version is actually 'prename':
> http://bbs.archlinux.org/viewtopic.php?pid=338101
>
>

That forum did contain the answer to my question. Classic rename is
part of util-linux, which seems to have been stripped out in Ubuntu
version .... (Why oh why?).. I'll do some testing to confirm this.

(Note, for the record, prename looks pretty cool.. I'm just old
fashioned and set in my ways)

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 06:59 PM
"Paul Johnson"
 
Default Where art thou 'rename'

On Tue, Aug 5, 2008 at 1:41 PM, Romain Kang <romain@kzsu.stanford.edu> wrote:
> Here's something posted to USENET ca. 1991. I've been carrying around
> my own copy ever since:
>
> #! /usr/local/bin/perl
> $op = shift;
> for (@ARGV) {
> $was = $_;
> eval $op;
> die $@ if $@;
> rename($was,$_) unless $was eq $_;
> }
>
> --

I've been using this same scritp since 1995. It is from the Unix
Powertools examples, I think. Anyway, my version has some usage
examples at the top. I don't think people could figure it out without
them. If you know perl or sed s/before/after/ this will be familiar
to you.
###########################

#!/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 $_;
}


##########################

Here are some examples I regularly do after downloading things

## replace spaces with _ in all file names ending in mp3

rename s/ /_/g *.mp3

(recall the g means "for all instances". Without it, it only does first one).

## Change " - " to "-"

rename s/ - /-/ g *

## THis accepts regular expressions, so you can use ^ and $ in a handy way.

### Insert "My" at beginning of all file names

rename s/^/My/ *

### Add "-orig" to end of all file names

rename s/$/-orig/ *

Anything you can do with Perl/sed and regex



--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 07:05 PM
Rashkae
 
Default Where art thou 'rename'

Paul Johnson wrote:
> On Tue, Aug 5, 2008 at 1:41 PM, Romain Kang <romain@kzsu.stanford.edu> wrote:
>> Here's something posted to USENET ca. 1991. I've been carrying around
>> my own copy ever since:
>>
>> #! /usr/local/bin/perl
>> $op = shift;
>> for (@ARGV) {
>> $was = $_;
>> eval $op;
>> die $@ if $@;
>> rename($was,$_) unless $was eq $_;
>> }
>>
>> --
>
> I've been using this same scritp since 1995. It is from the Unix
> Powertools examples, I think. Anyway, my version has some usage
> examples at the top. I don't think people could figure it out without
> them. If you know perl or sed s/before/after/ this will be familiar
> to you.
> ###########################
>
> #!/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 $_;
> }
>
>
> ##########################
>
> Here are some examples I regularly do after downloading things
>
> ## replace spaces with _ in all file names ending in mp3
>
> rename s/ /_/g *.mp3
>
> (recall the g means "for all instances". Without it, it only does first one).
>
> ## Change " - " to "-"
>
> rename s/ - /-/ g *
>
> ## THis accepts regular expressions, so you can use ^ and $ in a handy way.
>
> ### Insert "My" at beginning of all file names
>
> rename s/^/My/ *
>
> ### Add "-orig" to end of all file names
>
> rename s/$/-orig/ *
>
> Anything you can do with Perl/sed and regex
>
>
>

Ok, I've finished answering my own question.

the program you describe is actually already implemented and installed.
It's called prename.

In Ubuntu, rename is an alt link that points to prename (ie, you don't
need your own script, it's already included, and the new version. Also,
the new prename doesn't overwrite existing files unless you use the -f
option)

The rename from util-linux I'm familiar with is in a binary named
reanme.ul Fair enough. Now I just need to figure out the proper way of
changing an alternative in Ubuntu. But that's low priority for me atm.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-05-2008, 07:18 PM
Romain Kang
 
Default Where art thou 'rename'

> the program you describe is actually already implemented and installed.
> It's called prename.

Good to know.

Of course, if you use lots of platforms other than Ubuntu, the
8-line version is easy to drop in on the fly. You can run it on
other Linuxes or the BSDs. You can run it on Windows boxes with
Cygwin, or even Windows with ActiveState Perl (with a wee bit of
tweaking). It's short enough to type by hand if you don't have any
other way to get it onto your target system.

Oops, I'm raving. Please excuse...

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 10:29 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org