K, well... Shawn came through for me on MSN again. Thanks!
Beta 3 has all I asked for and more.
Code:
; Script to copy tapes from SAN to LTO
; by Les Ligetfalvy
BREAK ON
DIM $label,$frame1,$frame2,$frame3,$label2,$cmd1,$cmd2,$cmd5,$
GLOBAL $form,$Text4,$Text5,$form2,$list1,$list2,$list3,$label1,$OptionButton1,$OptionButton2,$CheckBox1
$ = SetOption('explicit','on')
$Form = CreateObject('Kixtart.Form')
$Form.Caption = 'GUI TapeCopy - beta 3'
$Form.Width = 420
$Form.Height = 500
$Form.Center
$label = $Form.Label('Note that only M or TM tapes will show in the lists. Only one tape copy/merge job'
+ @CRLF + 'is allowed at one time. Merge job will follow shortly after the copy job completes.'
+ @CRLF + 'Newly merged LTO tapes will not appear in the list without another Filter Load.',10,10,400,40)
$Frame1 = $Form.GroupBox('Select SAN Tape',10,55,240,160)
$Frame2 = $Form.GroupBox('Action Steps',260,55,140,337)
$Frame3 = $Form.GroupBox('Existing LTO Tapes',10,220,240,172)
$list1 = $Frame1.Listbox(,10,20,220,130)
$list2 = $Frame3.Listbox(,10,20,220,142)
$list1.OnClick = 'List1OnClick()'
$list2.OnClick = 'List2OnClick()'
$label2 = $Frame2.Label('1: Load Filter'
+ @CRLF + @CRLF + '2: Select SAN Tape'
+ @CRLF + @CRLF + '3: Copy Tape'
+ @CRLF + @CRLF + '4: Repeat or Exit',10,20,100,110)
$cmd1 = $Frame2.Button('&Load Filter',10,140,120,30)
$cmd1.onclick = 'onbutton1click() $$list1.setfocus'
$cmd2 = $Frame2.Button('&Copy',10,180,120,30)
$cmd2.onclick = 'onbutton2click() $$list1.setfocus'
$cmd5 = $Frame2.Button('E&xit',10,220,120,30)
$cmd5.onclick = 'onbutton5click() $$list1.setfocus'
$list3 = $Form.Listbox(,9,400,395,60)
$list3.OnClick = 'List3OnClick()'
$Form.Show
$list1.setfocus
WHILE $Form.Visible
$=Execute($Form.DoEvents())
LOOP
EXIT 0
;----------------
;Start of KF UDFs
;----------------
FUNCTION List1OnClick()
DIM $
FOR $ = 0 to $list2.listcount - 1
$list2.listindex = $
IF 'T'+$list1.text = $list2.text
$list3.additem('WARNING, '+$list2.text+' ALREADY EXISTS!',0)
$list3.listindex = 0
EXIT 1
ELSE
$list2.listindex = -1
$list3.listindex = -1
ENDIF
NEXT
ENDFUNCTION
FUNCTION List2OnClick()
$list2.listindex = -1
ENDFUNCTION
FUNCTION List3OnClick()
$list3.listindex = -1
ENDFUNCTION
FUNCTION onbutton1click ;SELECT Group and Date
DIM $label3,$savebtn,$label4,$label5,$label6,$,$Frame4,$Frame5
$Form2 = CreateObject('Kixtart.Form')
$Form2.Caption = 'BrightStor Filter Settings'
$Form2.Width = 400
$Form2.Height = 300
$Form2.Center
$Frame4 = $Form2.GroupBox('Date Range',10,28,182,190)
$Frame5 = $Form2.GroupBox('Filter Options',202,28,182,190)
$label3 = $Form2.Label('Enter a date in the format 01/28/05',10,10,390,30)
$savebtn = $Form2.CommandButton('Load and Return',150,230)
$savebtn.onclick = 'onbutton6click()'
$label4 = $Frame4.Label("Date:",10,28,48,15)
$label4.alignment = 1
$Text4 = $Frame4.Textbox(Split(@date,'/')[1]+'/'+Split(@date,'/')[2]+'/'+Right(Split(@date,'/')[0],2),60,25,90,20)
$label5 = $Frame4.Label("Group:",10,154,48,15)
$label5.alignment = 1
$Text5 = $Frame4.Textbox('SRV1_D',60,151,90,20)
$OptionButton1 = $Frame5.OptionButton("After Date",30,25,150,20)
$OptionButton2 = $Frame5.OptionButton("Before Date",30,50,150,20)
$OptionButton1.checked = 1
$CheckBox1 = $Frame5.Controls.CheckBox("All Groups",30,150,150,20)
$Form2.Show
While $Form2.Visible
$=Execute($Form2.DoEvents())
Loop
ENDFUNCTION
FUNCTION onbutton2click ;Copy
;Sample TapeCopy CMD
; TapeCopy -s SRV2_D -d LTO -t M-SRV2-SAT-05/28/05 -c TM-SRV2-SAT-05/28/05 -m MLY_TAPE -g
DIM $S,$D,$T,$C,$M,$G,$TapeCopyCMD
SELECT
CASE $list1.text = -1
$list3.additem(@time + ' - NO TAPE SELECTED, NOTHING TO COPY!',0)
EXIT 1
CASE Left($list1.text,1) = 'M'
$S = ' -s '+Split($List1.text,'-')[1]+'_D'
$D = ' -d LTO'
$T = ' -t '+$list1.text
$C = ' -c T'+$list1.text
$M = ' -m MLY_TAPE'
$G = ' -g'
$TapeCopyCMD = 'C:\Program Files\CA\BrightStor ARCserve Backup\TapeCopy.exe'+$S+$D+$T+$C+$M+$G
$list3.additem(@time + ' - Tape '+$list1.text+' copy to T'+$list1.text,0)
$list3.listindex = 0
$form.mousepointer = 11
WHILE NOT EXIST('C:\Program Files\CA\BrightStor ARCserve Backup\CATALOG.DB\T'+Join(Split($list1.text,'/'),'-')+'.*')
SLEEP 1
LOOP
$form.mousepointer = 1
$list3.additem(@time + ' - DONE!',0)
$list3.listindex = 0
EXIT 1
CASE 1
$list3.additem(@time + ' - DOH!',0)
EXIT 1
ENDSELECT
ENDFUNCTION
FUNCTION onbutton5click ;Exit
QUIT 1
ENDFUNCTION
FUNCTION onbutton6click ;Load Filter
DIM $Folder,$Date,$Group,$FolderArray[6],$SGroup
$Date = $text4.text
$Group = $text5.text
$form2.mousepointer = 11
$list1.clear
$list2.clear
FOR each $Folder in dirplus("C:\Program Files\CA\BrightStor ARCserve Backup\CATALOG.DB","/ad")
$FolderArray = Split(Split(Split($Folder,'CATALOG.DB\')[1],'.')[0],'-')
$Folder = Join($FolderArray,'-',4)+'/'+$FolderArray[4]+'/'+$FolderArray[5]
IF $FolderArray[0] = 'M' or $FolderArray[0] = 'TM'
$SGroup = $FolderArray[1]+'_D'
SELECT
CASE $CheckBox1.checked
SELECT
CASE $optionButton1.checked
IF Right($Folder,8) <= $Text4.text
IF $FolderArray[0] = 'M'
$list1.additem($Folder)
Else
$list2.additem($Folder)
ENDIF
ENDIF
CASE $optionButton2.checked
IF Right($Folder,8) >= $Text4.text
IF $FolderArray[0] = 'M'
$list1.additem($Folder)
Else
$list2.additem($Folder)
ENDIF
ENDIF
ENDSELECT
CASE not $CheckBox1.checked
IF $Group = $SGroup
SELECT
CASE $optionButton1.checked
IF Right($Folder,8) <= $Text4.text
IF $FolderArray[0] = 'M'
$list1.additem($Folder)
Else
$list2.additem($Folder)
ENDIF
ENDIF
CASE $optionButton2.checked
IF Right($Folder,8) >= $Text4.text
IF $FolderArray[0] = 'M'
$list1.additem($Folder)
Else
$list2.additem($Folder)
ENDIF
ENDIF
ENDSELECT
ENDIF
ENDSELECT
ENDIF
NEXT
$list3.listindex = -1
$list3.additem(@time + ' - ' + 'Logging started',0)
$list3.additem('Date filter = '+IIF($optionButton1.checked,'After','Before')+' '+$Text4.text,0)
$list3.additem('Group filter = '+IIF($CheckBox1.checked,'All',$Group),0)
$form2.mousepointer = 1
$form2.hide
ENDFUNCTION
;----------------
; End of KF UDFs
;----------------
FUNCTION DirPlus($path,optional $Options, optional $f, optional $sfflag)
;Author Bryce Lindsay bryce@isorg.net
IF not vartype($f) DIM $f ENDIF
IF not vartype($sfflag) DIM $sfflag ENDIF
DIM $file, $i, $temp, $item, $ex1, $mask,$mask1,$maskArray,$maskarray1,
$ex2, $code, $CodeWeight, $targetWeight, $weight, $masktrue
DIM $tarray[0]
$ex1 = SetOption(Explicit,on)
$ex2 = SetOption(NoVarsInStrings,on)
$codeWeight = 0
IF not Exist($path) Exit(2) ENDIF
IF not vartype($f)
$f = CreateObject("Scripting.FileSystemObject").getfolder($path)
ENDIF
IF @ERROR
$temp = SetOption(Explicit,$ex1)
$temp = SetOption(NoVarsInStrings,$ex2)
Exit(@ERROR)
ENDIF
FOR Each $temp In Split($options,"/")
$temp=Trim($temp)
SELECT
CASE left($temp,1) = "s"
IF not vartype($sfflag)
IF Val(right($temp,-1)) = 0
$sfflag = -1
Else
$sfflag = Val(right($temp,-1))
ENDIF
ENDIF
CASE Left($temp,1) = "a"
SELECT
CASE Right($temp,-1)="d"
$codeWeight = $codeWeight + 1
$temp = "IF $file.type = 'File Folder' "
CASE Right($temp,-1)="-d"
$codeWeight = $codeWeight + 1
$temp = "IF $file.type <> 'File Folder' "
CASE Right($temp,-1)="s"
$codeWeight = $codeWeight + 1
$temp = "IF $file.attributes & 4 "
CASE Right($temp,-1)="-s"
$codeWeight = $codeWeight + 1
$temp = "IF ($file.attributes & 4)=0 "
CASE Right($temp,-1)="h"
$codeWeight = $codeWeight + 1
$temp = "IF $file.attributes & 2 "
CASE Right($temp,-1)="-h"
$codeWeight = $codeWeight + 1
$temp = "IF ($file.attributes & 2)=0 "
CASE Right($temp,-1)="r"
$codeWeight = $codeWeight + 1
$temp = "IF $file.attributes & 1 "
CASE Right($temp,-1)="-r"
$codeWeight = $codeWeight + 1
$temp = "IF ($file.attributes & 1)=0 "
CASE Right($temp,-1)="a"
$codeWeight = $codeWeight + 1
$temp = "IF $file.attributes & 32 "
CASE Right($temp,-1)="-a"
$codeWeight = $codeWeight + 1
$temp = "IF ($file.attributes & 32)=0 "
ENDSELECT
$code = $temp + "$weight=$weight+1 ENDIF" +@CRLF + $code
CASE Left($temp,1) = "m"
$maskarray = Split(Right($temp,-2),"|")
$codeweight = $codeweight + 1
$code = "$masktrue=0 FOR Each $mask in $maskarray IF instr($file.name,$mask) $masktrue=1 " +
"ENDIF NEXT IF $masktrue $weight=$weight+1 ENDIF" + @CRLF +$code
CASE Left($temp,1) = "f"
$maskarray1 = Split(Right($temp,-2)," ")
$codeweight = $codeweight + 1
$code = "$masktrue=0 FOR Each $mask1 in $maskarray1 IF substr($file.name,Instrrev($file.name,'.')+1)" +
"=$mask1 $masktrue=1 ENDIF NEXT IF $masktrue $weight=$weight+1 ENDIF" + @CRLF +$code
ENDSELECT
NEXT
$code = "$weight = 0 $targetWeight = " + $codeweight + @CRLF + $code
$code = $code + "IF $weight = $targetweight Exit(1) ENDIF"
FOR Each $file In $f.subfolders
IF Execute($code)
$tarray[$i] = $file
$i = $i + 1
ReDIM preserve $tarray[$i]
ENDIF
IF $sfflag
$temp = dirplus($file,$options,$file,$sfflag-1)
FOR Each $item In $temp
$tarray[$i] = $item
$i = $i + 1
ReDIM preserve $tarray[$i]
NEXT
ENDIF
NEXT
FOR Each $file In $f.files
IF Execute($code)
$tarray[$i] = $file
$i = $i + 1
ReDIM preserve $tarray[$i]
ENDIF
NEXT
IF $i
ReDIM preserve $tarray[$i-1]
$i=0
Else
$tarray = 0
ENDIF
$dirplus = $tarray
$temp = SetOption(Explicit,$ex1)
$temp = SetOption(NoVarsInStrings,$ex2)
Exit(@ERROR)
ENDFUNCTION