Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #Written by Dalton Dick
- #v0.2.2
- #Defining some variables for easy changing
- $inputDir = "L:\\Handbrake\\Input\\";
- $outputDir = "L:\\Handbrake\\Output\\";
- $preset = '--preset iPod';
- #list of the supported conversion formats
- @fileFormats = qw/ .mpg .mkv .avi .wmv .mp4 .flv .m2ts /;
- #opens the directory and reads it into the array
- opendir(INPUT, $inputDir) or die ("Can't open the directory");
- @input = readdir(INPUT);
- #removes . and ..
- shift(@input);
- shift(@input);
- #prints all of the files found
- print "The files found are:\n";
- foreach (@input){
- print $_."\n";
- }
- $totalFiles = @input;
- print "Total files found is: $totalFiles\n";
- #Looping through the files
- foreach $file (@input){
- foreach $format (@fileFormats){
- if($file =~ m/.$format/i){
- $tail = length($format);
- $name = substr($file, 0, -$tail);
- $checkFile = $name . '.m4v';
- $string = $ouputDir.$checkFile;
- unless (-e "$outputDir$checkFile") {
- system('handbrakeCLI -i "' . $inputDir . $file . '"' . ' -o "' . $outputDir . $checkFile . '" ' . $preset);
- $filesConverted += 1;
- }#End unless statement
- }#End if statement
- }#End $format foreach loop
- }#End $file foreach loop
- print "Converted $filesConverted files\n";
Advertisement
Add Comment
Please, Sign In to add comment