Vbscript / Files And Folders / Auto Copy Files From Cdrom
This is a useful little script for dumping the contents of a CDROM or DVDROM to hard drive escpecially when you have a lot to do! It will keep running and eject the CDROM when the copy of files has finished so all you need to do is keep putting in a CD or DVD every time the drive opens. You will need to end the wscript (or cscript) process using task manager to end the script or simply shut down (or restart) the computer.
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell")On Error Resume Next CD = "E:" Dest = "r:" pollTime = 20 Do Until false replDir CD, Dest CreateObject("Shell.Application").Namespace(17).ParseName(CD).InvokeVerb("E&ject") iRetVal = objShell.Popup("Disk copy complete. Enter another disk and wait or click Cancel below to Quit",pollTime,"Idle...",vbRetryCancel + vbQuestion)
Select Case iRetVal Case vbRetry Case vbCancel Wscript.Quit End Select Loop Sub replDir(src, dest) On Error Resume Next Set objDir = objFSO.GetFolder(src) For Each file In objDir.Files If NOT objFSO.FileExists(dest & "" & file.Name) Then objFSO.CopyFile src & "" & file.Name, dest & "" & file.Name End If Next If Err.Number <> 0 Then Wscript.Echo("Error copying " & src & " to " & dest & ". " & Err.Description) Err.Clear On Error GoTo 0 End If For Each dir In objDir.SubFolders If NOT objFSO.FolderExists(dest & "" & dir.Name) Then objFSO.CreateFolder dest & "" & dir.Name End If replDir src & "" & dir.Name, dest & "" & dir.Name Next End Sub
Please note that a disclaimer applies to any code on this page.
|