[unix] rename files to lowercase

eldiet

Limp Gawd
Joined
Dec 5, 2001
Messages
511
Hey

I have some 500+ oracle forms that I would like to rename to all lower case. Or I need to make them not case dependant when linked from a windows webserver.

And actually both would be ideal.

Thanks for any help.

Edit: nm, i found something. here it is, if anyone else ends up looking for it at some time
http://www.lagom.nl/linux/shell-scripts/

Code:
#!/usr/bin/perl -w

if ($#ARGV == -1) {
    print("Usage: flowercase file ...\n".
	  "  Rename to lowercase names. Also replace spaces by underscores.");
    exit(1);
}

foreach $fn (@ARGV) {
    $nfn = $fn;
    $nfn =~ tr!A-Z !a-z_!;
    if ($nfn eq $fn) {
	print("$fn: no change.\n");
    } elsif (-f $nfn) {
	print("$fn -> $nfn: file already exists.\n");
    } else {
	print("$fn -> $nfn\n");
	rename($fn, $nfn) || print("  $!\n");
    }
}
 
Back
Top