Renaming MCM Video Files with PowerShell

Windows_PowerShell_icon-102x102This should be a quick post, but it might help someone with an problem I was running into.  Note that I’m just starting to learn PowerShell, so take that into account when reading…

Lately, I’ve been using Aaron Nelson’s (blog | @sqlvariant) awesome script to download all of the SQL Server MCM (Microsoft Certified Master) training videos automagically.  I updated his script to grab the .MP4 versions of the files instead of the .WMVs since I’m watching them on my iPhone.

When the script pulls the files from the MCM site, they are named with a ridiculously long prefix, like this:  HDI-ITPro-TechNet-ipod-MCM_01_DataStructures.mp4.  That’s all well and good, except when I put them on my iPhone, it ends up looking like this:


The names don’t scroll, and unlike with music, turning the phone to landscape doesn’t show anything differently.  Since I can only see the prefix, I’m left to guess which video I’ll be watching.  As fun as that is, I would rather be able to tell clearly which video is which.

In comes a very short PowerShell script.  I use this script to strip the long prefix from all of the MCM video files in my videos folder (actually, calling it a “script” is probably an exaggeration).

get-childitem *.mp4 | foreach { rename-item $_ $_.Name.Replace("HDI-ITPro-TechNet-ipod-MCM_","") }

Sync with the phone and, ta-da…


Ahh, much better.  Aaron’s script is smart enough to only download the video files you don’t already have.  So when new videos were released this morning, I ran the following to put the filenames back the way they were before running his script again.

get-childitem *.mp4 | foreach { rename-item $_ $_.Name.Replace($_.Name,"HDI-ITPro-TechNet-ipod-MCM_" + $_.Name) }

Simple but useful.  I love PowerShell because it’s so intuitive – it’s easy to look at these snippets of code and tell exactly what it’s doing.

If anyone knows of a better way to handle this, either in the script or on the iPhone, please leave a comment.  Thanks!

And by the way, if you haven’t heard, the MCM videos are awesome.  I think they are worth watching by any SQL Server professional, even if they currently have no interest in pursuing an MCM certification.  The MCM video site is here, and supplemental information on the SQLSkills site is here.

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Renaming MCM Video Files with PowerShell

  1. Pingback: Tweets that mention Renaming MCM Video Files with PowerShell | Dave's SQL Blog --

  2. Thanks for this quick script! I’m watching them on my iphone too, and I had just synced a handful to watch in a rotation. I’ve committed the next 30 lunches to learning Powershell. Your post was just one more reason to learn! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *