WorldTeacher

Script

Jun 4th, 2021 (edited)
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $current_path = Get-Location
  2. $start = $current_path
  3. $directories = get-childitem -path $current_path -Recurse -Directory
  4. Foreach ($dir in $directories) {
  5.     Set-Location -literalpath $dir.fullname
  6.  
  7.     Get-ChildItem *.mkv | where BaseName -notlike '*`[HEVC]' | foreach {
  8.   # Convert the input file and send ffmpeg's output to the display,
  9.   # by piping to Write-Host, rather than trough the pipeline.
  10.   ffmpeg -i $_ -c:v libx265 -c:a copy -x265-params crf=25 "$($_.BaseName) [HEVC].mkv" -y |
  11.     Write-Host
  12.   # Conversion OK? Output the file-info object, which pipes it to Remove-Item.
  13.   if ($LASTEXITCODE -eq 0) { $_ }
  14. } | Remove-Item -force
  15.  
  16.  
  17.  
  18.  }
  19. cd $start
  20. pause
Add Comment
Please, Sign In to add comment