forked from trapd00r/utils
/
findmvid
executable file
·56 lines (48 loc) · 1.1 KB
/
findmvid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl
use strict;
use File::Lscolor qw(ls_color);
use Term::ExtendedColor qw(fg);
my @disks = qw(
Mvids
Mvids_2
);
my %foo = %{ find(@ARGV) };
my $i = 1;
my $prev_chr;
for my $movie(sort(keys(%foo))) {
my($chr) = $movie =~ /(.)/;
$chr = '#' if $chr =~ /^\d+$/;
if($prev_chr ne $chr) {
printf(" %s\n", fg('bold', fg('red1', $chr)));
$prev_chr = $chr;
}
my($movie_disk_no) = $foo{$movie} =~ /(\d+)$/;
$movie_disk_no += 8;
printf("% 5d: %33s [ %s ]\n",
$i, fg("yellow$movie_disk_no", $foo{$movie}),
(-f "$foo{$movie}/$movie") ? ls_color($movie) : fg('blue4', $movie),
);
$i++;
}
sub find {
my $term = shift;
if(!defined($term)) {
my(undef, undef, undef, undef, undef, $year) = localtime(time);
$year += 1900;
$term = $year;
}
my %results;
chdir('/mnt/') or die($!);
for my $disk(@disks) {
for my $movie(glob("$disk/*")) {
#next if ! -d $movie;
if($movie =~ s;(.+)/(.+)$;$2;) {
my $mountpoint = $1;
if($movie =~ /$term/i) {
$results{$movie} = $mountpoint;
}
}
}
}
return \%results;
}