title: PowerShell script ffmpeg
body: <p>Being the good Windows systems admin that I am, I'm finally getting around to learning PowerShell. With that being said, I have no idea what I'm doing (surprise, surprise).</p>
  
  <p>I thought that it would be a good learning experience for me to play around with PowerShell at home, far away from my production environment. Recently, I've begun using FFMPEG to convert all of my .mkv files to .mp4 so I could have better playback support to my PlayStation 3 via Plex, and thought that this would be a good learning experience.</p>
  
  <p>The command I've been running is as follows: </p>
  
  <pre><code>ffmpeg -i OldVideoName.mkv -vcodec copy -acodec ac3 OldVideoName.mp4
  </code></pre>
  
  <p>What I want is have a PowerShell script that will run once, scanning a folder and all sub-folders for .mkv files (Get-ChildItem ".*.mkv"), transcode them to .mp4 via the above command, and place them in the same location as the .mkv with the same naming scheme.</p>
  
  <p>Example of running the script with D:\Videos as the target directory:</p>
  
  <p>D:\Videos\home_dvr\movies\video1.mkv --> D:\Videos\home_dvr\video1.mp4
  D:\Videos\home_dvr\tv\video2.mkv --> D:\Videos\home_dvr\tv\video2.mp4</p>
  
  <p>As you can guess, I can't figure it out for the life of me. Here's the latest attempt before giving up.</p>
  
  <pre><code>    $oldvid = Get-ChildItem .\*.mkv -Recurse
      $newvid = $oldvid.Name.split(‘.’)[0]; ForEach-Object {
              .\ffmpeg.exe -i $oldvid -y -vcodec copy -acodec ac3 $newvid".mp4”
      }
  </code></pre>
  
  <p>Any help would be appreciated!</p>