I have a bunch of folder in my local hard disk. Below is the folders name :
3 ABC
abc movie (2002) HDTVRip 576p Hindi Eng BHATTI87
Bcd [2011].720p.BRRip.x264.[Dual Audio] [Hindi+English].by K@rtik [ExD Exclusive]
def (2007)
Gaf-DVDRip-AVI
Gadks Of Wc (2012) - DVDRip - 1CD - XviD - Subs - [xDM]
Kah - DVDScr - XviD - 1CDRip - [DDR]
kaslf.kasl .Ljasj [2007] - x264 - AAC - 1 CD DVDRip - ESubs - MDG
I want all the name have some similarity like between each string there should be one space i.e “Gadks Of Wc (2012) – DVDRip – 1CD – XviD – Subs – [xDM]” should be
Gadks Of Wc (2012) DVDRip 1CD XviD Subs [xDM].
My logic was :
- Read the each folder name
- Store all the folder name in a list
- Do operation like split and join on each name
Below is my script :
#!/usr/bin/perl -w
use strict;
my $dir_name = "E:/movie";
opendir READ, $dir_name
or die"Can not found it $!";
my @name = readdir(READ);
my (@split_name, $update_movie_name, $fix_movie_name);
foreach my $name (@name) {
@split_name = split /[\s+\/.\-]/,$name;
$update_movie_name = movie_fun(@split_name);
}
sub movie_fun {
foreach my $movie (@split_name) {
$fix_movie_name = join("",$movie);
}
return ($fix_movie_name);
}
With this script I am only getting last part of the folder name. I don’t know where am I doing mistake. Please help me out of this problem. So that i can move my next step which will be deleting junk part from the name i.e “(2012) – DVDRip – 1CD – XviD – Subs – [xDM]”,(2007) etc
If any body can give me any other way to proceed for this problem then also will be fine.
Thanks
Thanks
OUTPUT