Awesome little script to do bulk rename of files posted on MandrivaUsers.org by Steve Scrimpshire.


#!/usr/bin/perl -w
# rename – Larry’s filename fixer
$op = shift or die “Usage: rename expr [files]\n”;
chomp(@ARGV = ) unless @ARGV;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}

Create a new file in /usr/bin rename.pl with the above contents.

chmod +x /usr/bin/rename.pl

Now you can do something like this to bulk rename files:

rename.pl ‘s/[0-9]+-//g’ *

This requires some knowledge of Regular Expressions.

bulk rename bash script – MandrivaUsers.org

Be Sociable, Share!

Subscribe to comments Comment | Trackback |
Post Tags: ,

Browse Timeline


Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*

Powered by WP Hashcash


© Copyright 2007 KafeKafe . Thanks for visiting!