Hi All,
I am trying to organize my song directory and trying to remove the duplicate entries, I have written a small code but somehow I am not able to rename the song name.
I am trying to change all the song name to uppercase and then removing the spaces, any number and other characters.
I also want to remove the duplicate songs but couldn't figure out how to apply it??
Thanks for the help
Kumar
I am trying to organize my song directory and trying to remove the duplicate entries, I have written a small code but somehow I am not able to rename the song name.
I am trying to change all the song name to uppercase and then removing the spaces, any number and other characters.
Code:
#!/usr/bin/perl use strict; use warnings; my $cnt = 1; my $folder = "/home/kk/song/latest"; my @files = `ls $folder/*.mp3 *.MP3`; my @sorted = sort { lc($a) cmp lc($b) } @files; foreach my $file(@sorted) { my $name = $file; $name=~ tr/a-z/A-z/; $name=~ s/\.MP3//g; $name=~ s/\.mp3//g; chomp $name; $name=~ s/_/ /g; $name=~ s/__/ /g; $name=~ s/[0-9]//g; $name=~ s/\s+/ /g; $name=~ s/\(.*\)//g; # print "$name\n"; my $newname = $name.".MP3"; system 'mv',"$file", "/home/kk/song/latest/$newname"; # print "$newname\n"; $cnt++; } print "$cnt\n";
Thanks for the help
Kumar
Comment