0

Hi I am trying to change the files names in some of my folders in windows machine.

I have bunch of files with files names starting with caiptal letter example

"Hello.html" but i want to change that to "hello.html" since there are like thousands of files i cannot just go and do it change it manually. I am looking for a script and i just need some help to get started and what should i start with.

I have access to a linux machine i can just copy the files over there and run any scripts i would really appreciate if some one could guide me to get started either in Linux or windows environments.

oortcloud_domicile
  • 840
  • 6
  • 21
  • 41

2 Answers2

1

On some linux system you can use the rename command, which accept regular expression. Try the following:

rename 's/^([A-Z])/\l$1/' *

This should replace any uppercase char at the beginning with a lower case one.

Othewise, if you're not running a linux system that accept such a command, you can write your own little perl script:

#!/usr/bin/perl
use strict;
use warnings;
use File::Copy;

my @files = `ls`;

foreach (@files) {
    chomp($_);
    if ($_ =~ m/^[A-Z]/) {
        my $newname = $_;
        $newname =~ s/^([A-Z])/\l$1/;
        move($_, $newname);
    }
}

exit 0;
Zagorax
  • 11,440
  • 8
  • 44
  • 56
0

A very easy to use option is ReNamer.

Once installed, simply add the files to be renamed and add a case rule to simply change it to lower case or add a regex rule for advanced cases.

Roney Michael
  • 3,964
  • 5
  • 30
  • 45