Re: Stupid spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 01:23 PM 02/12/2004, Alok K. Dhir wrote:
The attached rename.pl is invaluable for such tasks.

Use it exactly like your bash rename attempt. You can use pretty much any perl in-place-modifier construct - s/X/Y/, tr/A-Z/a-z/ (upper->lower), etc.

Not sure where I found this originally, but it's extremely handy.


#!/usr/bin/perl


if (@ARGV == 0) {
    die "usage: rename PATTERN FILESPEC\n";
}

$pattern=shift;

foreach (@ARGV) {
    my $oldname=$_;
    my $newname=$_;
    eval ("\$newname=~$pattern");
    rename($oldname, $newname);
}

Very. Thanks. Not a BASH script, but works great.


Thanks.

-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux