+sub create_playlists {
+ my ($dstdirs) = @_;
+
+ foreach $dstdir (@{$dstdirs}) {
+ print "-> Recreating playlists in: $dstdir\n";
+ print "-> Creating playlists for each month & year of clips from this directory: $video_directory\n";
+ opendir(VIDEODIR, "$dstdir") or die "-E- could not open: $dstdir\n";
+ chdir "$dstdir" || die "-E- Unable to change directory to the dstdir: $dstdir\n";
+
+ my @all_files = readdir VIDEODIR;
+ closedir(VIDEODIR);
+ @all_files = sort @all_files;
+
+ print " Removing all existing playlists from the directory\n";
+ if(! defined $opt_t) { system("rm *.$playlist_extension > /dev/null 2>&1"); }
+
+ foreach $file (@all_files) {
+ next if -d $file;
+ next if ($file !~ /\.avi$/i && $file !~ /\.mpg$/i && $file !~ /\.mkv$/i && $file !~ /\.3gp$/i && $file !~ /\.mov$/i && $file !~ /\.mts$/i);
+ if($file =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
+ $year = $1; $month = $2;
+ print " Adding $file to $year.$playlist_extension & $year-$month.$playlist_extension\n";
+ if(! defined $opt_t) { system("echo \"$file\" >> $year.$playlist_extension"); }
+ if(! defined $opt_t) { system("echo \"$file\" >> $year-$month.$playlist_extension"); }
+ } else {
+ print " Skipping $file since we can't extract the year and month from it\n";
+ }
+ }
+ }
+}
+
+# Sanity checks / Option processing