Last active
October 16, 2015 09:24
-
-
Save n7st/5aef685fa2a80855fe2f to your computer and use it in GitHub Desktop.
Report albums in your music directory per year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
# Dates to report between ($in 2000, $out 2015) | |
my ($in, $out); | |
my $output = './albums_per_year_output/'; | |
Getopt::Long::GetOptions( | |
'in=i' => \$in, | |
'out=i' => \$out, | |
); | |
die 'Missing parameters.' if !$in || !$out; | |
mkdir $output if ! -d $output; | |
foreach ($in..$out) { | |
my $file_name = "$output$_.txt"; | |
my $this_year = `find . -type d -name "*$_*"`; | |
if ($this_year) { | |
open (my $fh, '>', $file_name) or die "Could not write to $file_name."; | |
print $fh $this_year; | |
close $fh; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements
Usage
cd /path/to/music/
perl /path/to/albumsbyyear.pl -in 2000 -out 2015
cd albums_per_year_output
cat *.txt
Output example