X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=organize_videos;h=86047a1a65fdc6785a771e7a86816d134512e12b;hb=32f5e50c17ae4efc216a50ef2cecae7e2dcf6508;hp=754ac28124e8c17079678527a77a204d28c295e9;hpb=6868d6dcb3b2aa816c411ccc640a38d73980df15;p=videoscripts%2F.git diff --git a/organize_videos b/organize_videos index 754ac28..86047a1 100755 --- a/organize_videos +++ b/organize_videos @@ -14,13 +14,15 @@ use File::Pid; my $srcpathname = "/naspool/pictures/New Photos"; # Path to look for videos to move from my $dstpathname = "/naspool/videos/HomeVideos"; # Path to move the videos to my $merge_videos_by_day = "/naspool/videos/bin/merge_videos_by_day"; -my $minage = "+10"; # File creation dates must be older than X minutes to move +my $minage = "+30"; # Video file creation dates must not have changed in the last X minutes to process any of the video files my $owner = "ajp"; # The owner of the files after they are moved my $group = "pip"; # The group of the files after they are moved my $mode = "664"; # The mode to set on each file after they are moved my $playlist_extension = "pls"; # The extension to use when creating playlist files my $video_suffix = "000"; # What number to start with when adding an incrementing suffix to the end of the final video clip to avoid name collisions -my $find_cmd = "find \"$srcpathname/\" -cmin $minage -a \\( -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\" -o -iregex \".*\.mkv\" \\)"; +my $movie_file_ext = "-iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\" -o -iregex \".*\.mkv\""; +my $find_changed_cmd = "find \"$srcpathname/\" -not -cmin $minage -a \\( $movie_file_ext \\)"; +my $find_cmd = "find \"$srcpathname/\" $movie_file_ext"; #################################################################################################### # Sanity check @@ -123,6 +125,10 @@ if(defined $opt_p) { $video_files_found=`$find_cmd`; if(!$video_files_found) { exit 0; } +# Only proceed if no files have changed in the past $cmin minutes +$changed_files_found=`$find_changed_cmd`; +if($changed_files_found) { exit 0; } + # Only one instance of this script running at a time my $pidfile = File::Pid->new({file => "/tmp/organize_videos.pid"}); exit if $pidfile->running(); @@ -137,7 +143,7 @@ my $merge_opts = ""; if(defined $opt_t) { $merge_opts .= "-t "; } if(defined $opt_r) { $merge_opts .= "-r "; } $errno=system("$merge_videos_by_day -s \"$srcpathname\" $merge_opts"); -if($errno > 0) { $errno = $errno - 255; } +$errno = $errno >> 8; if($errno) { die "-E- $merge_videos_by_day encountered some errors with exit code $errno\n"; } # Copy the videos over to the destination path @@ -189,7 +195,7 @@ foreach $file (`$find_cmd`) { $newfile = $dstfile . "." . $video_suffix; if(-e "$newfile.$ext") { foreach $i ($video_suffix+1 .. '999') { - $newfile = $dstfile . "." . $i; + $newfile = $dstfile . "." . sprintf("%03d",$i);; if(! -e "$newfile.$ext") { last; } } $dstfile = $newfile;