<commit_before>#!/usr/bin/perl

my @files = `ls -ld /Volumes/CAM_MEM/SD_VIDEO/PR* | tr -s " "`;
foreach(@files){
  chomp;
  $file = $_;
  $file =~ /(\S*)\s(\S*)\s(\S*)\s(\S*)\s(\S*)\s(\S*)\s(\S*)\s(\S*)\s(\S*)/;
  $month = $6;
  $day = $7;
  $year = $8;
  $fn = $9;

  if($year =~ /:/){
    $year = "2012";
  }

  if($month eq "Jan"){
    $month = "01";
  }
  if($month eq "Feb"){
    $month = "02";
  }
if($month eq "Mar"){
$month = "03";
} 
if($month eq "Apr"){
$month = "04";
}
if($month eq "May"){
$month = "05";
}
if($month eq "Jun"){
$month = "06";
}
if($month eq "Jul"){
$month = "07";
}
if($month eq "Aug"){
$month = "08";
}
if($month eq "Sep"){
$month = "09";
}
if($month eq "Oct"){
$month = "10";
}
if($month eq "Nov"){
$month = "11";
}
if($month eq "Dec"){
$month = "12";
}

if($day =~ /^\d$/){
  $day = "0" . $day;
}

  @allfiles = `ls $fn | grep MOD`;
  foreach(@allfiles){
    chomp;
    $dest_file = $year . "_" . $month . "_" . $day . "_" . $_;
    print "copying '$fn/$_' to '//Users/jasonfehr/Movies/transfer/$dest_file'\n";
    `cp $fn/$_ //Users/jasonfehr/Movies/transfer/$dest_file`;
  }
  print "$year $month $day\n";
}<commit_msg>updated to use perl functions instead of file info from ls command<commit_after>#!/usr/bin/perl

#perl script to directly copy movies from a video camera to the local disk

use 5.012;
use strict;
use warnings;
use Getopt::Std qw(getopts);
$|++;

my $SOURCE_DIRECTORY = "/Volumes/CAM_MEM/SD_VIDEO/";
my $DEFAULT_OUTPUT_DIRECTORY = "/Users/jasonfehr/Movies/transfer/";

my $output_directory;
my %opts;
my @file_stats;
my @file_modify_time;


#process output directory location from command line
getopts("o:", \%opts);
if(defined($opts{"o"})){
  $output_directory = $opts{"o"};
}else{
  $output_directory = $DEFAULT_OUTPUT_DIRECTORY;
}

#read all directories that contain movies
foreach my $dir (`ls -d $SOURCE_DIRECTORY/PR*`){
  chomp $dir;
  print "Reading directory '$dir'\n";
  
  #movies for each day are stored in the same directory, therefore we can use the last modified time 
  #from each directory (which assumes no on-camera editing has taken place)
  @file_stats = stat($dir);
  @file_modify_time = localtime($file_stats[9]);
  
  #loop through all movies in the directory
  foreach my $file (`ls $dir/MOV*.MOD`){
    my $dest_file;
    
    chomp $file;
    $file =~ /(MOV.*)\.MOD$/;
    
    #destination filename is in the format yyyy_mm_dd_MOVddd.MOD
    $dest_file = $output_directory . "/" . 
                 ($file_modify_time[5] + 1900) . "_" . 
                 td($file_modify_time[4] + 1) . "_" .
                 td($file_modify_time[3]) . "_" . 
                 $1 . ".MOD";
    
    print "copying '$file' to '$dest_file'\n";
    `cp $file $dest_file`;
  }
  print "\n";
}

#function to zero pad a number
sub td{
  my $digits = shift();
  
  return $digits < 10 ? "0$digits" : $digits;
}
{'fraction_non_alphanumeric': 0.20349040139616056, 'fraction_numerical': 0.017452006980802792, 'mean_word_length': 3.0884450784593436, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2163772', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1118, 'n_words': 287}