You are not logged in.

#1 2007-12-12 22:29:31

alphahsk
Member
From: Norway
Registered: 2007-01-22
Posts: 40

Bash 'rename' utility different in Arch & Ubuntu

The rename command in bash on my ubuntu box allows for Perl regular expressions for mass renaming of files:
Synopsis: 

rename perlexpr [ files ]

The rename command in Arch bash is a more simple one:
Synopsis:

rename from to [ files ]

Is it possible to get the ubuntu version of 'rename' for arch ??

Offline

#2 2007-12-13 00:20:28

elide
Member
From: Russia
Registered: 2007-12-02
Posts: 40

Re: Bash 'rename' utility different in Arch & Ubuntu

cat > ~/bin/rename #or sudo tee `which rename` (not recommended)
#!/usr/bin/perl
$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 $_;
}

then make sure that you have $HOME/bin first in your PATH.

Offline

#3 2007-12-13 19:49:09

Bison
Member
From: Jacksonville, FL
Registered: 2006-04-12
Posts: 158
Website

Re: Bash 'rename' utility different in Arch & Ubuntu

ls | egrep 'regex' | xargs -I {} cp {} new/path/

Offline

#4 2008-03-05 00:06:00

G_Syme
Member
Registered: 2007-01-04
Posts: 83

Re: Bash 'rename' utility different in Arch & Ubuntu

alphahsk wrote:

Is it possible to get the ubuntu version of 'rename' for arch ??

Yup, it is now available in the AUR. smile

For further information on the topic, you might want to look at this thread.


The courageous enter dark caves alone.
The clever send in the courageous first.
The cleverest wait behind the clever.

Offline

Board footer

Powered by FluxBB