#StandWithUkraine

Dumping multiply discs to hard drive with AutoIt

autoit icon There are very few tasks easier than copying some files from CD/DVD to hard drive:

  1. Insert disc.
  2. Select files.
  3. Drag’n’drop them.

Until you have to do this over 50 times - it gets ugly boring real fast. :)

I had recently bought new HDD (Western Digital 640Gb) to have it available for backup and future replacement of my main drive which approaches 30000 hours of uptime. Since it more than twice the size of old one I also get some extra space to dump stuff (mostly anime :) ) I borrowed from friend like months ago and never got to it.

Problem is stuff is in quantity of few dozens DVD discs. :) I had posted on AutoIt as tool to solve small problems and this one is exactly one of those.

I am going to walk through it step by step and combine into complete script in the end (you may just skip to that if bored).

  1. First we must decide what we want to do. Taking current task this means deciding on source, destination and files we want to copy. In AutoIt terms it is defining some variables. They are not commands and those names are just the ones I picked myself and paths are those I have on my PC:
$disc = "h:\" 
$dir = "k:\" 
$mask = "*.*" 
  1. Check for a disc in drive (we had previously defined as $disc so using that):
If DriveStatus($disc)="READY" Then
  1. Looking for files we need on disc (at least one):
$search = FileFindFirstFile($disc & $mask)
$file = FileFindNextFile($search)
  1. If there are some (’not @error’ part) and they are not copied yet let’s dump all of them to our directory and beep when done:
If Not @error And Not FileExists($dir & $file) Then
	FileCopy($disc & $mask, $dir)
	Beep()
EndIf

Now simply combining all parts and looping it (to run continuously) we end up with something like this:

$disc = "h:\"
$dir = "k:\"
$mask = "*.*"
While 1
	If DriveStatus($disc)="READY" Then
		$search = FileFindFirstFile($disc & $mask)
		$file = FileFindNextFile($search)
		If Not @error And Not FileExists($dir & $file) Then
			FileCopy($disc & $mask, $dir)
			Beep()
		EndIf
		FileClose($search)
	EndIf
	Sleep(1000)
WEnd

Exit

To stop script click its icon autoit in the tray and choose exit (might be slow in the middle of copying).

As long as it is running just put disc into drive and wait for beep to switch for next disc. So instead of wasting time eyeing copy progress I wrote this post while my bunch of discs to dump is steadily decreasing. :)

Download script https://www.rarst.net/script/disccopy.au3

AutoIt download page http://www.autoitscript.com/autoit3/downloads.shtml

Related Posts

1 Comments

  • Nihar #

    Nice script.