Requirement
I have a bunch of DVD’s that I want to archive to hard-disk so I can dispose of the DVDs.
Automate the process as much as possible.
Note: This is not a DVD copy protection crack, the DVD’s have to be copyable by the OS.
Synopsis
This script will wait for the DVD volume name to be NOT NULL
When a DVD is inserted, the script automatically creates a new folder in the destination root path, using the DVD name as the destination folder name.
After completing the copy it ejects the DVD drive and loops back into the waiting state.
Features
- Disk insertion detection (not based on auto-run)
- Destination folder name duplication protection via folder-name suffix (this prevents DVDs of the same name overwriting each-other)
- Simple copy integrity check using source and destination length comparison
- Speech so I can hear it from the next room when the DVD needs to be changed out
To Do
I’m wondering if using [System.IO.StreamWriter would be faster, but I think the bottleneck would be in the DVD Read, not the disk write. Speculation only. Next time I use the script I’ll make that modification and see how it goes.
Disclaimer
My scripts are open source, free to use, come with neither warranty as to optimal performance nor suggestion that they are necessarily the best way to achieve anything.
<# DVD Copy Script V 2.0 This version speaks so I can hear it from the next room when it needs a new disk SYNOPSIS ---------------------------------------------------------------------- I have a bunch of DVD's that I want to archive to Hard Disk so I can dispose of the DVDs I want to automate it as much as possible. This script will wait for the DVD volumename to be not null When a DVD is inserted it automatically copies the DVD to a destination folder root using the DVD name as a new destination sub-folder After completing it pops open the dvd drive and loops back into waiting for disk mode This version uses speach so I can hear it from another room! FEATURES --------------------------------------------------------------------- * Speach * Destination folder name duplication protection * Simple copy integrity check using length #> # INCLUDES ---------------------------------------------------------------------- # add speach object Add-Type -AssemblyName System.speech $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer # FUNCTIONS --------------------------------------------------------------------- function popdisk(){ (new-object -COM Shell.Application).NameSpace(17).ParseName($dvdpath).InvokeVerb('Eject') } function testpath($tpath){ if ((test-path $tpath) -ne $true) { $speak.Speak('path does not exist ... all is done here"') return $tpath } else{ $speak.Speak('path exists, adding suffix and retesting') $tpath += "_1" $speak.Speak("new foldername is "+ $tpath) testpath "$tpath" } } function CopyDVD{ # Drives and Paths (omit \) $dvdpath = 'I:' #no slash $destpath = 'E:\DVDCOPY' #no slash While($true){ #Clear variables $volumename = $null $foldername = "" $drive ="" $speak.Speak('Waiting for disk') " Waiting for disk ... " | Out-Host #loop while disk volumename is null DO{ $drive = Get-WmiObject -Class Win32_CDROMDrive $volumename = $drive.volumename }while ($volumename -eq $null) #disk detected get source details $speak.Speak('Disk detected, obtaining details.') $foldername = $volumename.ToString() #Check for duplicate folder and suffix number if folder exists $speak.Speak('Disk name is ' + $volumename.ToString()) $source = Get-ChildItem "$dvdpath\VIDEO_TS\" -recurse | Measure-Object -Property length -Sum $sourceLength = $source.Sum start-sleep -seconds 10 $speak.Speak('Copying Disk.') " Copying disk " + $foldername | Out-Host " src len " + $sourceLength | Out-Host $speak.Speak('checking if destination path is already used ' + $volumename.ToString()) $validpath=(testpath "$destpath\$foldername") copy-item "$dvdpath\VIDEO_TS\" "$validpath\VIDEO_TS\" -Recurse -Force #get destination length $destChilds = Get-ChildItem "$validpath\VIDEO_TS\" | Measure-Object -Property length -Sum $speak.Speak('Checking destination integrity') $destLength = $destChilds.Sum " dst len " + $destLength | Out-Host if ($sourceLength -ne $destLength){ " Error! " | Out-Host $speak.Speak('ERROR ERROR ERROR ERROR ERROR') exit } Else{ "ok" | out-host } start-sleep -Seconds 10 $speak.Speak('Hello the D--V-D has finished!') $speak.Speak('Hello the D-V-D has finished!') " Finished " + $foldername | Out-Host # Eject CD popdisk start-sleep -Seconds 10 #end of while } #end of function } # MAIN ---------------------------------------------------------------------- "--------------- starting DVD Auto Copy" | Out-Host popdisk while ($true){ copyDVD }