Rumel

Handbrake Script v0.2.2

Apr 22nd, 2011
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.23 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #Written by Dalton Dick
  3. #v0.2.2
  4.  
  5. #Defining some variables for easy changing
  6. $inputDir = "L:\\Handbrake\\Input\\";
  7. $outputDir = "L:\\Handbrake\\Output\\";
  8. $preset = '--preset iPod';
  9.  
  10. #list of the supported conversion formats
  11. @fileFormats = qw/ .mpg .mkv .avi .wmv .mp4 .flv .m2ts /;
  12.  
  13. #opens the directory and reads it into the array
  14. opendir(INPUT, $inputDir) or die ("Can't open the directory");
  15. @input = readdir(INPUT);
  16.  
  17. #removes . and ..
  18. shift(@input);
  19. shift(@input);
  20.  
  21. #prints all of the files found
  22. print "The files found are:\n";
  23. foreach (@input){
  24.     print $_."\n";
  25. }
  26. $totalFiles = @input;
  27. print "Total files found is: $totalFiles\n";
  28.  
  29. #Looping through the files
  30. foreach $file (@input){
  31.     foreach $format (@fileFormats){
  32.         if($file =~ m/.$format/i){
  33.             $tail = length($format);
  34.             $name = substr($file, 0, -$tail);
  35.             $checkFile = $name . '.m4v';
  36.             $string = $ouputDir.$checkFile;
  37.             unless (-e "$outputDir$checkFile") {
  38.                 system('handbrakeCLI -i "' . $inputDir . $file . '"' . ' -o "' . $outputDir . $checkFile . '" ' . $preset);
  39.                 $filesConverted += 1;
  40.             }#End unless statement
  41.         }#End if statement
  42.     }#End $format foreach loop
  43. }#End $file foreach loop
  44.  
  45. print "Converted $filesConverted files\n";
Advertisement
Add Comment
Please, Sign In to add comment