Posted 30 December 2012 - 17:11
Posted 30 December 2012 - 17:25
Posted 30 December 2012 - 17:58
#!/usr/bin/perl
use strict;
# Array of movies to convert
my @MOVIES_TO_CONVERT = ('The Figher', 'The Fifth Element', 'Robinhood Men In Tights');
# Directory where the split AVI files are stored
my $MOVIE_IN_PATH = 'T:\Video\Movies';
# Directory where the combined AVI files will be stored
my $MOVIE_OUT_PATH = 'C:\_COMBINED_AVI';
# Full path to the avidemux executable
my $AVIDEMUX = 'C:\Programs\avidemux\avidemux.exe';
for my $movie (@MOVIES_TO_CONVERT)
{
my $convert_cmd = "\"$AVIDEMUX\" --load \"$MOVIE_IN_PATH\\$movie - CD1.avi\" --append \"$MOVIE_IN_PATH\\$movie - CD2.avi\" --force-smart --save \"$MOVIE_OUT_PATH\\$movie.avi\" --quit";
print "$convert_cmd\n";
die "Unable to convert $movie!\n" if (system "$convert_cmd");
}
Posted 30 December 2012 - 18:19
Posted 30 December 2012 - 18:54
Another question for you Orange, what would this look like as a VBS script? Do you know VBS? Just looking for something else to learn from since I'm in a Windows environment and wanted to start messing with VBS instead of batch. I learn best from understand code in scripts that I'm actually trying to use in real life instead of a test book.
I'm installing ActivePerl now and trying out that script on 2 movies.
Posted 30 December 2012 - 19:21
Ohhh, yeah I see what you mean. That would take awhile alright.I looked into that program and it doesn't provide any better options than that of Avidemux. I still have to manually join the files.
I have about 100 or more movies that are (movie-Cd1.avi and movie-Cd2.avi) and want to join them into one file. Avidemux works very well, but have to manually choose 2 files to join, then rinse and repeat 100+ times.
Posted 30 December 2012 - 19:27
Posted 30 December 2012 - 20:11
#!/usr/bin/perl
use strict;
########################################################################
# Configuration Details #
########################################################################
# Array of movies to convert
my @MOVIES_TO_CONVERT; # = ('The Figher', 'The Fifth Element');
# Directory where the split AVI files are stored
my $MOVIE_IN_PATH = 'T:\Video\Movies';
# Directory where the combined AVI files will be stored
my $MOVIE_OUT_PATH = 'C:\_COMBINED_AVI';
# Full path to the avidemux executable
my $AVIDEMUX = 'C:\Programs\avidemux\avidemux.exe';
########################################################################
# Functions #
########################################################################
# Return an array of all the AVI files in the specified directory.
sub get_avis_in_directory
{
my $dh; # Directory handle
my $dir; # Current directory
my @avis; # Array of file names to return
opendir ($dh, $dir = shift) or die "Failed to open directory $dir: $!\n";
while (readdir $dh)
{
next if (/^\.{1,2}/);
$_ = $dir . "\\" . $_;
push (@avis, $_) if (-f $_ and /.*\.avi$/i);
}
closedir $dh;
return (@avis);
}
########################################################################
# Entry Point #
########################################################################
die "Input directory $MOVIE_IN_PATH does not exist!\n" unless (-d $MOVIE_IN_PATH);
die "Output directory $MOVIE_OUT_PATH does not exist!\n" unless (-d $MOVIE_OUT_PATH);
# This variable represents the actual names and paths of movies to be converted.
# It will either be built from the files specified in @MOVIES_TO_CONVERT manually, or
# built dynamically based on the files in the source and destination paths.
my @movies_formatted; # Array of hashes of movies to convert
if ($#MOVIES_TO_CONVERT == -1)
{
my @in_avis; # Array of AVI files in the input directory
my @out_avis; # Array of AVI files in the ouput directory
@in_avis = get_avis_in_directory ($MOVIE_IN_PATH);
@out_avis = get_avis_in_directory ($MOVIE_OUT_PATH);
for my $in_avi (@in_avis)
{
if ($in_avi =~ /.*-[ ]*CD[ ]*1\.avi$/i)
{
my $rec; # Temporary hash variable
my $name; # Name of the move we are processing
$name = (split (/[ ]*-[ ]*CD[ ]*1/i, $in_avi))[0];
$name = (split (/$MOVIE_IN_PATH[\\\/]{1}/i, $name))[1];
for my $in_avi_2 (@in_avis)
{
if ($in_avi_2 =~ /^$MOVIE_IN_PATH\\$name[ ]*-[ ]*CD[ ]*2\.avi$/i)
{
$rec->{'part2'} = $in_avi_2;
last;
}
}
if (defined $rec->{'part2'})
{
for my $out_avi (@out_avis)
{
if ($out_avi =~ /$name\.avi$/i)
{
$rec->{'output'} = $out_avi;
last;
}
}
unless (defined $rec->{'output'})
{
$rec->{'part1'} = $in_avi;
$rec->{'output'} = "$MOVIE_OUT_PATH\\$name.avi";
push (@movies_formatted, $rec);
}
}
}
}
}
else
{
my $rec; # Temporary hash variable
for my $name (@MOVIES_TO_CONVERT)
{
$rec = {};
$rec->{'part1'} = "$MOVIE_IN_PATH\\$name - CD1.avi";
$rec->{'part2'} = "$MOVIE_IN_PATH\\$name - CD2.avi";
$rec->{'output'} = "$MOVIE_OUT_PATH\\$name.avi";
push (@movies_formatted, $rec);
}
}
for my $movie (@movies_formatted)
{
my $convert_cmd = "\"$AVIDEMUX\" --load \"" . $movie->{'part1'} . "\" --append \"" . $movie->{'part2'} . "\" --force-smart --save \"" . $movie->{'output'} . "\" --quit";
print "$convert_cmd\n";
die "Unable to convert $movie!\n" if (system "$convert_cmd");
}
Posted 30 December 2012 - 20:29
Funny how things work, been trying to do this script and now playing with perl and in the past hour I've been playing with PowerShell which is way cooler than I thought it was at first and found out it's replacing VBS pretty much.
I'm going to play with AutoIT more also. Thanks again Orange.
Posted 30 December 2012 - 20:54
Posted 30 December 2012 - 21:04
I'm looking at that new perl script that is more automated and playing with that too. Learning so much and it's fun. lol
Even though now I have many options of getting this done, I'm trying to make the perl, batch, and powershell work for the hell of it.
Posted 12 January 2013 - 22:43
Input directory T:\Video\Movies does not exist! Output directory C:\_COMBINED_AVI does not exist!
C:\>perl films.pl C:\>