Guest User

script to convert avisynth scripts into avi dummies

a guest
Aug 6th, 2012
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $MakeAVIS_Path = "C:\Program Files (x86)\ffdshow\makeAVIS.exe";
  2. $MakeAVIS_Timeout = 3 # seconds
  3.  
  4. #----------------------------------------------------------------------
  5. function Select-Folder($Message = 0, $Path = 0)
  6. {
  7.     $FolderSelectionDlg = New-Object -comObject Shell.Application    
  8.     $Folder = $FolderSelectionDlg.BrowseForFolder(0, $Message, 0, $Path)
  9.     if($Folder -ne $null)
  10.     {
  11.         $Folder.self.Path
  12.     }
  13. }
  14.  
  15. #----------------------------------------------------------------------
  16. # Main script body
  17.  
  18. # check provided makeAVIS path
  19. $FileExists = Test-Path $MakeAVIS_Path
  20. if($FileExists -eq $False)
  21. {
  22.     [Console]::WriteLine("Путь к makeAVIS указан неверно (""" + $MakeAVIS_Path + """).");
  23.     exit;
  24. }
  25.  
  26. # rise folder selection dialogs for source and output folders
  27. $ScriptsFolderPath = Select-Folder("Выберите папку с avisynth скриптами");
  28. if($ScriptsFolderPath -eq $null)
  29. {
  30.     exit;
  31. }
  32. $OutputFolderPath = Select-Folder("Выберите папку для avi-пустышек");
  33. if($OutputFolderPath -eq $null)
  34. {
  35.     exit;
  36. }
  37.  
  38. [Console]::WriteLine("Обрабатываем avisynth скрипты в """ + $ScriptsFolderPath + """");
  39. $FileEntries = [IO.Directory]::GetFiles($ScriptsFolderPath);
  40. $FilesCount = 0;
  41. foreach($FilePath in $FileEntries)
  42. {
  43.    if($FilePath.ToLower().EndsWith(".avs"))
  44.    {
  45.         $iFileNameStart = $FilePath.LastIndexOf("\");
  46.         $OutputFilePath = $OutputFolderPath + $FilePath.Substring($iFileNameStart, $FilePath.Length - 4 - $iFileNameStart) + ".avi";        
  47.        
  48.         # command line arguments for makeAVIS
  49.         # input script                  output video                    store input script in .avi dummy
  50.         # -i "C:\\Temp\TestVideo.avs"   -v "C:\\Output\TestVideo.avi"   -s 1
  51.         $makeAVIS_Args = " -i """ + $FilePath + """ -v """ + $OutputFilePath + """ -s 1";
  52.        
  53.         [Console]::WriteLine($FilePath.Substring($iFileNameStart + 1, $FilePath.Length - 1 - $iFileNameStart));
  54.         $MakeAVIS_Process = Start-Process -FilePath $MakeAVIS_Path -ArgumentList $makeAVIS_Args -WindowStyle Hidden -PassThru
  55.         Wait-Process -InputObject $MakeAVIS_Process -Timeout $MakeAVIS_Timeout -ErrorAction SilentlyContinue
  56.         Stop-Process -InputObject $MakeAVIS_Process -Force
  57.         $FilesCount = $FilesCount + 1;
  58.    }
  59. }
  60. [Console]::WriteLine("Обработано " + $FilesCount + " файлов.");
  61. [Console]::WriteLine("^_^");
RAW Paste Data