I ran into a curious problem recently. My wife had a massive binder full of DVDs that she’s collected over the years, and she wanted to get them archived to something a little more useful, like the media server that lives in our basement. After a couple hours of fiddling, I put together a nice solution where the end result is a server that waits to have a DVD inserted into it, rips that to a predefined network drive, and then sends an email and ejects the disk when it’s done. Here, I’ll show you how to set that up yourself.
Step 1: Get A Server
I suppose it doesn’t need to be a server, per-say, but at the end of the day you need some physical machine running Windows (or VMware, where you can pass the DVD drive through to a Windows VM). There are certainly Linuxy methods of doing this that are probably more reliable, and, well, better, but a Windows server is what I had on hand, so that is what this guide covers.
Step 2: Get MakeMKV
MakeMKV is a glorious little utility that automatically scans your DVDs (and blu-rays!), rips out the copyright protection, and converts any video files that are above a certain length. This means that you put a DVD in on one end, and get one or more meaty video files out of the other end, properly encoded and without any of the messy menu content.
Step 3: Write The Script
I did say we’d be using Powershell. Luckily, I’ve already got the script all made up for you. Run it as Administrator.
function Eject-CD # Great function for simply ejecting a CD drive. Originally sourced here: https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/ejecting-cd-drive { $drives = Get-WmiObject Win32_Volume -Filter "DriveType=5" if ($drives -eq $null) { Write-Warning "Your computer has no CD drives to eject." return } $drives | ForEach-Object { (New-Object -ComObject Shell.Application).Namespace(17).ParseName($_.Name).InvokeVerb("Eject") } } $storageFolder = "\\file.yournetwork.local\DVDBackups" # Where should things be backed up to? The script will create a folder inside this for each DVD processed. $toEmail = "toEmail@example.com" # The email address you want emails to come from $fromEmail = "fromEmail@example.com" # The email address you want emails to go to $retryWaitTime = 10 # How long (in seconds) to wait before checking to see if a DVD is in the drive $smtpServerHost = "mail.yournetwork.local" #If you have an unauthenticated SMTP server, you can just replace this address with that. If you need to use gmail or something like that, check out the docs for Send-MailMessage and adjust the commands below. $smtpServerPort = 25 # Whatever port your SMTP server uses $sendEmails= $true # Set this to $false to disable any email functionality, if you'd prefer not to set that up. while ($true){ if ((Get-WMIObject -Class Win32_CDROMDrive -Property *).MediaLoaded) { $movieName = (Get-Volume -DriveLetter D).FileSystemLabel.Trim() New-Item -Path "$storageFolder\" -Name $movieName -ItemType "directory" try { & "C:\Program Files (x86)\MakeMKV\makemkvcon64" mkv disc:0 all $storageFolder\$movieName if (!$noEmail) {Send-MailMessage -To $toEmail -From $fromEmail -Subject “$movieName Ripping Complete” -Body “Go put the next one in.” -SmtpServer $smtpServerHost -Port $smtpServerPort} Write-Information "Ripping Complete! Give me the next disk to eat." Eject-CD } catch { if (!$noEmail) {Send-MailMessage -To $toEmail -From $fromEmail -Subject “ERROR! $movieName Ripping Failed!” -Body “Please send help. <br /> Error: $_” -SmtpServer $smtpServerHost -Port $smtpServerPort} Write-Error "Ripping Failed! Help :(" Write-Error $_ exit } } else { Write-Host "No DVD in tray, waiting and trying again..." sleep $retryWaitTime } }
Results!
With that running, stick a DVD in the drive, and you should see something like this.
Folders will be named based on the name of the DVD volume. It’s not perfect, but I’ve made my way through a couple dozen movies and TV shows so far, and have yet to come across any conflicts. Enjoy!
Like this article? Have questions? Want another post about something else?
Put a comment below and let me know.