Copia de Seguridad De tu música

y programas personales para otros como tu, puede que te corrijan ;)
Responder
Avatar de Usuario
arkcrew
Profesional del Autoit
Mensajes: 506
Registrado: 28 Sep 2009, 19:17
Ubicación: Granada, España
Contactar:

Copia de Seguridad De tu música

Mensaje por arkcrew »

Hola a todos,

Esta es una aplicación que apenas llevo desarrollando un par de horas puesto que me dispuse a copiar mi música a una unidad externa y me encontré con la sorpresa de que tenía muchos discos nuevos descargados que no había actualizado en mi unidad externa, por lo que pensé que ir comprobando una a una cada discografía me llevaría horas así que pensé, con autoit seguro que tardo menos.. y bueno, efectivamente tardé menos, en un momento me comparaba los directorios y me mostraba lo que me faltaba por copiar.

La utilidad es sencilla y bueno, os la cuelgo para que la veáis, supongo que debe ser compatible con cualquier pc independientemente de como organice su biblioteca, yo desde luego la tengo en modo Artista\ Álbum pero supongo que eso dará igual claro.. total solo compara y copia..

Espero que os guste!!

Saludos!

Captura:

Imagen
Créditos: Pues bueno, la idea es mía, pero la función de copiado con progreso la encontré en el foro de autoit, más concretamente aqui:
http://www.autoitscript.com/wiki/FAQ#Ho ... ctories.3F
Eligiendo la primera opción, la de SumTingWong
[/url]
Código:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#include <File.au3>
#include <GuiListView.au3>

Global Const $FO_MOVE = 0x0001
Global Const $FO_COPY = 0x0002
Global Const $FO_DELETE = 0x0003
Global Const $FO_RENAME = 0x0004

Global Const $FOF_MULTIDESTFILES = 0x0001
Global Const $FOF_CONFIRMMOUSE = 0x0002
Global Const $FOF_SILENT = 0x0004
Global Const $FOF_RENAMEONCOLLISION = 0x0008
Global Const $FOF_NOCONFIRMATION = 0x0010
Global Const $FOF_WANTMAPPINGHANDLE = 0x0020
Global Const $FOF_ALLOWUNDO = 0x0040
Global Const $FOF_FILESONLY = 0x0080
Global Const $FOF_SIMPLEPROGRESS = 0x0100
Global Const $FOF_NOCONFIRMMKDIR = 0x0200
Global Const $FOF_NOERRORUI = 0x0400
Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800
Global Const $FOF_NORECURSION = 0x1000
Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000
Global Const $FOF_WANTNUKEWARNING = 0x4000
Global Const $FOF_NORECURSEREPARSE = 0x8000

#region Formulario
$Form1 = GUICreate("Music Backup", 444, 378, 282, 216)
$Label1 = GUICtrlCreateLabel("Biblioteca local", 16, 16, 75, 17)
$Label2 = GUICtrlCreateLabel("Biblioteca destino", 16, 44, 87, 17)
$Input1 = GUICtrlCreateInput("C:\Users\alberto\Music", 104, 13, 281, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$Input2 = GUICtrlCreateInput("H:\Musica", 104, 40, 281, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("...", 392, 12, 43, 22, $WS_GROUP)
$Button2 = GUICtrlCreateButton("...", 392, 39, 43, 22, $WS_GROUP)
$Group1 = GUICtrlCreateGroup("Archivos/Carpetas Inexistentes", 16, 104, 417, 265)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Comparar", 16, 72, 75, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Copiar Seleciconado", 104, 72, 107, 25, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Copiar Todo", 224, 72, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

$hListView = GUICtrlCreateListView("Archivo/Carpeta|Ruta", 25, 120, 400, 245)
_GUICtrlListView_SetColumnWidth($hListView, 0, 130)
_GUICtrlListView_SetColumnWidth($hListView, 1, 240)
#endregion Formulario

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$dir = FileSelectFolder("Seleccione ruta de origen", "", "")
If Not @error Then GUICtrlSetData($Input1, $dir)
Case $Button2
$dir = FileSelectFolder("Seleccione ruta de destino", "", "")
If Not @error Then GUICtrlSetData($Input2, $dir)
Case $Button3
_GUICtrlListView_DeleteAllItems($hListView)
comparar(GUICtrlRead($Input1), GUICtrlRead($Input2))
Case $Button4
copiar(1, GUICtrlRead($Input1))
Case $Button5
copiar(0, GUICtrlRead($Input1))

EndSwitch
WEnd


Func comparar($inicio, $destino)
$listadir = _FileListToArray($inicio)
For $a = 1 To UBound($listadir) - 1
If FileExists($destino & "\" & $listadir[$a]) Then
;Abro el directorio y lo comparo con el otro:
$dir = $inicio & "\" & $listadir[$a]
$lista_interna = _FileListToArray($dir)
For $b = 1 To UBound($lista_interna) - 1
If FileExists($destino & "\" & $listadir[$a] & "\" & $lista_interna[$b]) Then
Else
GUICtrlCreateListViewItem($lista_interna[$b] & "|" & $destino & "\" & $listadir[$a] & "\" & $lista_interna[$b] & "@" & $dir & "\" & $lista_interna[$b], $hListView)
EndIf
Next
Else
GUICtrlCreateListViewItem($listadir[$a] & "|" & $destino & "\" & $listadir[$a] & "@" & $inicio & "\" & $listadir[$a], $hListView) ; Archivo suelto
EndIf
Next
EndFunc ;==>comparar

Func copiar($tipo_accion, $origen)
$total = _GUICtrlListView_GetItemCount($hListView)

Select
Case $tipo_accion = 0 ; Todos
For $a = 0 To $total
$nombre = _GUICtrlListView_GetItemText($hListView, $a)
$ruta = _GUICtrlListView_GetItemText($hListView, $a, 1)
$split = StringSplit($ruta, "@")
$inicio = $split[2]
$final = $split[1]
_CopyWithProgress($inicio, $final)
Next
Case $tipo_accion = 1 ; Seleccionado
For $a = 0 To $total
If _GUICtrlListView_GetItemSelected($hListView, $a) = True Then
$nombre = _GUICtrlListView_GetItemText($hListView, $a)
$ruta = _GUICtrlListView_GetItemText($hListView, $a, 1)
$split = StringSplit($ruta, "@")
$inicio = $split[2]
$final = $split[1]
_CopyWithProgress($inicio, $final)
EndIf
Next
EndSelect
EndFunc ;==>copiar

Func _CopyWithProgress($sFrom, $sTo)
Local $SHFILEOPSTRUCT, $pFrom, $pTo, $aDllRet, $i, $nError = 0
$SHFILEOPSTRUCT = DllStructCreate("hwnd hwnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle")
DllStructSetData($SHFILEOPSTRUCT, "hwnd", 0)
DllStructSetData($SHFILEOPSTRUCT, "wFunc", $FO_COPY)
$pFrom = DllStructCreate("char[" & StringLen($sFrom) + 2 & "]")
DllStructSetData($pFrom, 1, $sFrom)
For $i = 1 To StringLen($sFrom) + 2
If DllStructGetData($pFrom, 1, $i) = Chr(10) Then DllStructSetData($pFrom, 1, Chr(0), $i)
Next
DllStructSetData($pFrom, 1, Chr(0), StringLen($sFrom) + 2) ; second null at the end
DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($pFrom))
$pTo = DllStructCreate("char[" & StringLen($sTo) + 2 & "]")
DllStructSetData($pTo, 1, $sTo)
DllStructSetData($pTo, 1, Chr(0), StringLen($sTo) + 2) ; second null at the end
DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($pTo))
DllStructSetData($SHFILEOPSTRUCT, "fFlags", BitOR($FOF_NOCONFIRMMKDIR, $FOF_NOCONFIRMATION, $FOF_NOERRORUI))
DllStructSetData($SHFILEOPSTRUCT, "fAnyOperationsAborted", 0)
DllStructSetData($SHFILEOPSTRUCT, "hNameMappings", 0)
DllStructSetData($SHFILEOPSTRUCT, "lpszProgressTitle", 0)
$aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
If @error Or $aDllRet[0] <> 0 Then
$aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
If Not @error Then $nError = $aDllRet[0]
EndIf
; test if button Abort was pressed
If DllStructGetData($SHFILEOPSTRUCT, "fAnyOperationsAborted") Then $nError = -1

$pFrom = 0
$pTo = 0
$SHFILEOPSTRUCT = 0
If $nError <> 0 Then
SetError($nError)
Return False
EndIf
Return True
EndFunc ;==>_CopyWithProgress
Adjuntos
Music Backup.png
Music Backup.png (232.55 KiB) Visto 1591 veces
Avatar de Usuario
BasicOs
Site Admin
Mensajes: 2085
Registrado: 21 Nov 2006, 19:24
Ubicación: El Internet - (Canarias, España)
Contactar:

Re: Copia de Seguridad De tu música

Mensaje por BasicOs »

Gracias por el aporte,
Salu22:)
Avatar de Usuario
Ximorro
Profesional del Autoit
Mensajes: 1500
Registrado: 10 Jul 2009, 12:35
Ubicación: Castellón, España

Re: Copia de Seguridad De tu música

Mensaje por Ximorro »

¡Un GUI muy profesional!
"¿Y no será que en este mundo hay cada vez más gente y menos personas?". Mafalda (Quino)
Responder