Tkx Chr, the script work fine with ur UDF
I donīt know much on programming, Iīm Dummy, this is the full code until now, but still working... and learnig...
(Req: kixforms.dll 2.3.0 Final)
Code:
SetConsole("hide")
Break On
; Hide Files not copied
If Exist("N:\RENOVACI\DATOS.INI")
$FileExt=ReadProfileString("N:\RENOVACI\DATOS.INI","VALORES","FILEXT")
$Destino=ReadProfileString("N:\RENOVACI\DATOS.INI","VALORES","DESTINO")
$Exclusiones=ReadProfileString("N:\RENOVACI\DATOS.INI","VALORES","EXCLUSIONES")
Else
$=MessageBox("Imposible abrir el archivo con los datos para realizar el backup, se continuara con los datos basicos","Informacion",48,15)
$FileExt=".doc;.xls;.ppt;.zip;.nsf"
$Destino="C:\TEST" ;EL DEFINITIVO SERA "F:\BACKUP\"
If Right($Destino,1)<>"\" $Destino=$Destino+"\" EndIf
$Exclusiones="DBLIB4.nsf","favorite.nsf","helplt4.nsf","iccon.nsf","log.nsf","lsxlc.nsf","perweb.nsf","readme.nsf"
EndIf
$Destino=$Destino+@WKSTA
$System = CreateObject("Kixtart.System")
$FORM = CreateObject("Kixtart.FORM")
$FORM.CAPTION = "Resplaldo Archivos Renovacion Tecnologica"
$FORM.SCALEHEIGHT = 402
$FORM.SCALEWIDTH = 600
$FORM.FONTNAME = "Arial"
$FORM.FONTSIZE = 9
$FORM.ICON = $System.BuiltinIcons(51)
$fraBanner = $FORM.PictureBox
$fraBanner.BACKCOLOR = $FORM.RGB(255,255,255)
$fraBanner.HEIGHT = 70
$fraBanner.Left = 10
$fraBanner.TOP = 10
$fraBanner.WIDTH = 585
$picBanner = $fraBanner.Image
$picBanner.Picture = "shell32.dll;23"
$picBanner.HEIGHT = 60
$picBanner.Left = 5
$picBanner.TOP = 5
$picBanner.WIDTH = 60
$fraDetails = $FORM.Frame("Detalles")
$fraDetails.HEIGHT = 300
$fraDetails.Left = 8
$fraDetails.TOP = 95
$fraDetails.WIDTH = 585
$fraTotales = $FORM.Frame("Totales")
$fraTotales.TOP = 280
$fraTotales.HEIGHT = 50
$fraTotales.Left = 11
$fraTotales.WIDTH = 579
; Dibujar Banner
$fraBanner.FONTSIZE = 20
$fraBanner.FONTNAME = "verdana"
$fraBanner.ForeColor = 0
$fraBanner.PrintXY(70,0,"Respaldo de Informacion")
$fraBanner.FONTSIZE = 8
$fraBanner.ForeColor = $FORM.RGB(0,100,100)
$fraBanner.PrintXY(73,32,"Gerencia de Redes Locales")
$fraBanner.FONTBOLD = 1
$fraBanner.FONTSIZE = 11
$fraBanner.PrintXY(273,46,"Bienvenido")
$fraBanner.FONTBOLD = 0
$fraBanner.FONTSIZE = 10
; Forma de Lista de archivos
$List = $Form.ListView
$List.Top = 115
$List.Left = 15
$List.Width = 570
$List.Height = 150
$List.MultiSelect = 1
$List.OnDoubleClick = "Delete_Click()"
$List.Sorted = 2 ; Yes, sort the first column
$List.MultiSelect = True ; Allow more than one selection
$List.GridLines = True ; Show gridlines in report view
$List.FullRowSelect = True ; Allow user to select the entire row
$FileName = $List.Columns.Add
$FileName.FontSize = 12
$FileName.Text = "Nombre"
$FileName.Width = (355)
$FileSize = $List.Columns.Add
$FileSize.Text = "Tamaņo"
$FileSize.Width = (65)
$FileSize.Alignment = 1
$FileDate = $List.Columns.Add
$FileDate.Text = "Fecha"
$FileDate.Width = (125)
$FileDate.Alignment = 1
;************* Salir **************
$Salir = $Form.ToolButton
$Salir.Enabled = "True"
$Salir.FlatStyle = 2
$Salir.Left = 495
$Salir.Text = "Salir"
$Salir.Top = 355
$Salir.Visible = "True"
$Salir.Width = 75
$Salir.Icon = 60
$Salir.FontSize = 7
$Salir.Onclick = "quit()"
;**********************************
;************* Procesar ***********
$Procesar = $Form.ToolButton
$Procesar.Enabled = "True"
$Procesar.FlatStyle = 2
$Procesar.Left = 30
$Procesar.Text = "Procesar"
$Procesar.Top = 355
$Procesar.Visible = "True"
$Procesar.Width = 75
$Procesar.Icon = 10
$Procesar.FontSize = 7
$Procesar.Onclick = "OnButtonClick()"
;**********************************
;************* Examinar ***********
$Examinar = $Form.ToolButton("Browse...")
$Examinar.Enabled = "True"
$Examinar.FlatStyle = 2
$Examinar.Left = 230
$Examinar.Text = "Adicionar"
$Examinar.Top = 355
$Examinar.Visible = "True"
$Examinar.Width = 75
$Examinar.Icon = 1
$Examinar.FontSize = 7
$Examinar.Onclick = "$$nul = BrowseForFile_Click()"
;**********************************
;************* Eliminar ***********
$Eliminar = $Form.ToolButton
$Eliminar.Enabled = "True"
$Eliminar.FlatStyle = 2
$Eliminar.Left = 310
$Eliminar.Text = "Remover"
$Eliminar.Top = 355
$Eliminar.Visible = "True"
$Eliminar.Width = 75
$Eliminar.Icon = 44
$Eliminar.FontSize = 7
$Eliminar.OnClick = "Delete_Click()"
;**********************************
$objFSO = CreateObject("Scripting.FileSystemObject")
$Drives = $objFSO.Drives
For Each $Drive In $Drives
If $Drive.Drivetype = 2
$Origen=$Drive+"\temp" ; Eliminar +"\temp" en la ver final
$ListaCompleta=DirPlus($Origen,$FileExt,1)
$Archivos=UnirArreglos($Archivos,$ListaCompleta)
EndIf
Next
For Each $Ex In $Exclusiones
$Archivos=FilterArray($archivos,$Ex)
Next
For Each $File In $Archivos
$ItemFile = $List.Items.Add
$ItemFile.SubItems(0).Text = "$File"
$ItemFile.SubItems(1).Text = GetFileSize("$File")
$ItemFile.SubItems(2).Text = GetFileTime("$File")
$tam=$tam+GetFileSize($file)
Next
$lblTotales = $FORM.Label
$lblTotales.CAPTION = "Cantidad Archivos"
$lblTotales.HEIGHT = 20
$lblTotales.WIDTH = 110
$lblTotales.Left = 90
$lblTotales.TOP = 301
$totalarchivos = $FORM.TextBox
$totalarchivos.HEIGHT = 19
$totalarchivos.Left = $lblTotales.Left+110
$totalarchivos.TOP = 300
$totalarchivos.TextAlign = 1
$tac=$List.Items.Count
$totalarchivos.Text = $tac
$totalarchivos.WIDTH = 40
$lblTotalTa = $FORM.Label
$lblTotalTa.CAPTION = "Total Espacio en disco"
$lblTotalTa.HEIGHT = 20
$lblTotalTa.WIDTH = 140
$lblTotalTa.Left = $totalarchivos.Left+80
$lblTotalTa.TOP = 301
$totalarchivosTa = $FORM.TextBox
$totalarchivosTa.HEIGHT = 20
$totalarchivosTa.Left = $lblTotalTa.Left+140
$totalarchivosTa.TOP = 300
$totalarchivosTa.TextAlign = 1
$totalarchivosTa.Text = $tam
$totalarchivosTa.WIDTH = 80
$lblMegabytes = $FORM.Label
$lblMegabytes.CAPTION = "Bytes"
$lblMegabytes.HEIGHT = 20
$lblMegabytes.WIDTH = 60
$lblMegabytes.Left = $totalarchivosTa.Left+80
$lblMegabytes.TOP = 301
$FORM.Center
$FORM.Show
$List.SetFocus
While $FORM.Visible
$=Execute($FORM.DoEvents)
Loop
Exit 1
Function OnButtonClick()
$c=1
$t=$List.Items.Count
For Each $Item In $List.Items
$String = $Item.Text
$Wait = CreateObject("Kixtart.FORM")
$Wait.FONTSIZE = 14
$Wait.FONTNAME = "Arial"
$Wait.PrintXY(25,35,"Realizando Backup, espere un momento por favor... $c de $t")
$Wait.FONTSIZE = 10
$Wait.PrintXY(25,65,"$String")
$Wait.CENTER
$Wait.Icon = $System.BuiltinIcons(7)
$Wait.CAPTION = "Backup..."
$Wait.SCALEWIDTH = 550
$Wait.SCALEHEIGHT = 100
$Wait.Show
$an=Left($string,1)
$string="disco_"+$an+SubStr($string,3,1000)
$cutpath=getfilepath($String,1)
$acu=$destino
For Each $element In $cutpath
$acu=$acu+"\"+$element
If NOT Exist($acu) MD $acu EndIf
Next
$Orig=$Item.Text
$Dest=$Destino+"\"+$String
$Desti=getfilepath($Dest)
GUICopy($orig, $Desti,4) ;Para mover con GUICopy("c:\origen", "E:\",0,1)
If $c=$t $Wait.Hide EndIf
$c=$c+1
Next
EndFunction
Function BrowseForFile_Click()
Dim $f
$f = $form.Dialogs.OpenFileDialog
$f.Filter = "Todos los Archivos (*.*)|*.*|Microsoft Word (*.doc)|*.doc|Microsoft Excel (*.xls)|*.xls|Microsoft Powerpoint (*.ppt)|*.ppt|Lotus Notes - Base de datos (*.nsf)|*.nsf|Lotus Notes - ID (*.id)|*.id"
If $f.ShowDialog = 1
$BrowseForFile_Click = $f.Filename
EndIf
If $BrowseForFile_Click
For Each $Item In $List.Items
$String = $Item.Text
If InStr($String,$BrowseForFile_Click)
MessageBox("El archivo seleccionado ya aparece en el listado","Seņor Usuario",48)
$Item.Selected = 1
$List.SetFocus
Return
EndIf
Next
$tac=$List.Items.Count+1
$tam=$tam+GetFileSize($BrowseForFile_Click)
$totalarchivos.Text = $tac
$totalarchivosTa.Text = $tam
$ItemFile = $List.Items.Add
$ItemFile.SubItems(0).Text = $BrowseForFile_Click
$ItemFile.SubItems(1).Text = GetFileSize($BrowseForFile_Click)
$ItemFile.SubItems(2).Text = GetFileTime($BrowseForFile_Click)
$List.SetFocus
EndIf
EndFunction
Function Delete_Click()
If $Form.MsgBox("Esta seguro que desea eliminar los elementos seleccionados del listado?","Borrar",4) = 6
$Form.MousePointer = 11
$Form.Enabled = 0
$Form.BeginUpdate
$List.SelectedItems.Clear
$Form.EndUpdate
$Form.MousePointer = 0
$Form.Enabled = 1
$tacd=0
$tamd=0
For Each $Item In $List.Items
$tacd=$tacd+1
$tamd=$tamd+GetFileSize($Item.Text)
Next
$tac=$tacd
$tam=$tamd
$totalarchivos.Text = $tac
$totalarchivosTa.Text = $tam
$List.SetFocus
Return
EndIf
EndFunction
Function GUICopy($sSrc, $sDest, OPTIONAL $lFlags, OPTIONAL $bMove)
Dim $sVer,$objShell,$objFldr
If NOT Exist($sSrc) Exit 2 EndIf
If NOT Exist($sDest) Exit 3 EndIf
If @INWIN=1
$sVer=GetFileVersion(%WINDIR%+"\System32\Shell32.dll","FileVersion")
Else
$sVer=GetFileVersion(%WINDIR%+"\System\Shell32.dll","FileVersion")
EndIf
If $sVer<"4.71" Exit 10 EndIf
$objShell=CreateObject("Shell.Application")
$objFldr=$objShell.NameSpace($sDest)
If @ERROR<0 Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
Select
Case $bMove=1 $objFldr.MoveHere($sSrc,$lFlags)
Case $bMove=0 $objFldr.CopyHere($sSrc,$lFlags)
Case 1 Exit 87
EndSelect
If @ERROR<0 Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
Exit @ERROR
EndFunction
Function getfilepath($filespec, optional $seg)
If InStr($filespec,'\')
$getfilepath=Split($filespec,'\')
ReDim preserve $getfilepath[Ubound($getfilepath)-1]
If NOT Val($seg)
$getfilepath=Join($getfilepath,'\')
EndIf
Else
$getfilepath=''
EndIf
EndFunction
Function UnirArreglos($Array1, $Array2)
Dim $n,$i
$n = Ubound($Array1) + 1
ReDim PRESERVE $Array1[$n+Ubound($Array2)]
For $i = 0 to Ubound($Array2)
$Array1[$n+$i] = $Array2[$i]
Next
$UnirArreglos = $Array1
EndFunction
Function FilterArray($array,$find, optional $inclusive)
Dim $lf, $t, $l, $sp
$lf=Chr(10) $sp=Chr(32)
If NOT VarType($Array) & 8192 Exit(1) EndIf
For Each $l In $array
If (InStr($l,$find) AND $inclusive AND Trim($l)> $sp)
OR (NOT InStr($l,$find) AND NOT $inclusive AND Trim($l)> $sp)
$t=$t+$lf+$l
EndIf
Next
$FilterArray=Split(SubStr($t,2),$lf)
EndFunction
Function DirPlus($Dir, $mask, optional $subfolders, optional $datatype, optional $verbose)
Dim $SubDirIndex, $SubDirSize, $SubDirSizeInc
$SubDirSize = 0
$SubDirSizeInc = 16
$SubDirIndex = -1
Dim $arrSubdir[$SubDirSize]
Dim $FileArrayIndex, $FileArraySize, $FileArraySizeInc
$FileArraySize = 0
$FileArraySizeInc = 16
$FileArrayIndex = -1
Dim $arrFile[$FileArraySize]
Dim $fso, $arrMask, $file, $filename, $filedata, $ext
If NOT $Dir Exit 1 EndIf
If NOT Exist($Dir) Exit 2 EndIf
If Right($Dir,1) <> "\"
$Dir = $Dir + '\'
EndIf
If $verbose $Dir+Chr(13) EndIf
If $datatype=1
$fso = CreateObject("scripting.filesystemobject")
EndIf
If $mask = 0 $mask = "*.*" EndIf
$arrMask = Split($mask,";")
$file = Dir($Dir + "*.*")
While $file AND (NOT @error)
If ($file <> ".") AND ($file <> "..")
$filename = $Dir + $file
$filedata = 0
If GetFileAttr($filename) & 16
;-- this is a directory --
If $SubFolders
; add the foldername to an array of subdir
$SubDirIndex = $SubDirIndex + 1
If $SubDirIndex > $SubDirSize
$SubDirSize = $SubDirSize + $SubDirSizeInc
$SubDirSizeInc = $SubDirSizeInc * 2
ReDim preserve $arrSubDir[$SubDirSize]
EndIf
$arrSubDir[$SubDirIndex] = $file
If $datatype=1
$filedata = $fso.getfolder($filename)
EndIf
EndIf
Else
;-- this is a file --
$ext = InStrRev($filename,".")
If $ext
$ext = SubStr($filename,$ext)
If AScan($arrMask,$ext) <> -1
If $datatype=1
$filedata = $fso.getfile($filename)
Else
$filedata = $filename
EndIf
EndIf
EndIf
EndIf
If $filedata <> 0
;-- add filename in the result array --
$FileArrayIndex = $FileArrayIndex + 1
If $FileArrayIndex > $FileArraySize
$FileArraySize = $FileArraySize + $FileArraySizeInc
$FileArraySizeInc = $FileArraySizeInc * 2
ReDim preserve $arrFile[$FileArraySize]
EndIf
$arrFile[$FileArrayIndex] = $filename
EndIf
EndIf
$file = Dir("")
Loop
If $SubFolders
If $SubDirIndex > -1
;-- there are subdirs : scan subdir --
ReDim preserve $arrSubDir[$SubDirindex]
Dim $SubDir, $arrSubDirFiles
For Each $SubDir In $arrSubDir
$arrSubDirFiles = DirPlus( $Dir+$SubDir, $mask, $SubFolders, $DataType, $verbose )
For Each $file In $arrSubDirFiles
$FileArrayIndex = $FileArrayIndex + 1
If $FileArrayIndex > $FileArraySize
$FileArraySize = $FileArraySize + $FileArraySizeInc
$FileArraySizeInc = $FileArraySizeInc * 2
ReDim preserve $arrFile[$FileArraySize]
EndIf
$arrFile[$FileArrayIndex] = $file
Next
Next
EndIf
EndIf
If $verbose RPad("",Len($Dir)," ")+Chr(13) EndIf
If $FileArrayIndex > -1
ReDim preserve $arrFile[$FileArrayIndex]
$DirPlus = $arrFile
Exit 0
Else
Exit 3
EndIf
EndFunction