den ganzen Code.... ok
C
$target = @ScriptFullPath
$Laufwerk = StringLeft($target, StringInStr($target, ":\", Default, -1) +0)
#include <GUIConstantsEx.au3>
#include <FTPEx.au3>
#include <MsgBoxConstants.au3>
Local $sServer = 'xx.xxx.xx.xxx' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
Local $sUsername = 'xxxxxxxx'
Local $sPass = 'xxxxxx'
Local $Download_Datei_gefunden
$FTP_Pfad = "/USB_Stick/Ordner/"
$Festplatte_Pfad = $Laufwerk & "/ORDNER/"
Local $hOpen = _FTP_Open('Mein FTP-Control')
Local $verbinde_FTP_Server = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) ;Anmelden an FTP-Server
If @error Then
MsgBox(0, "_FTP_Connect", "Keine Verbindung zum FTP-Server möglich" & @error)
Else
;----------- alle Dateien mit Ordner ermitteln ------------
Local $Download_Pfad_mit_Datei[200][30]
Local $Download_Pfad_mit_Datei_2[200][30]
Local $Download_Pfad_Ordner[200][2]
local $Checkbox_ID [200]
Local $ss = 1
Local $ff = 2
Local $eee = 0
Local $gg = 0
Local $Unter_pfad = ""
;-------------- Dateifpad und Dateien ermitteln ---------------
For $x = 1 to 15 ;Schleife zur ermittlichn der vorhandenen Ordner
If $x > 1 and $Download_Pfad_Ordner[$x][0] = "" Then ExitLoop
_FTP_DirSetCurrent ($verbinde_FTP_Server, $FTP_Pfad & $Download_Pfad_Ordner[$x][0] ) ;wird benötigt um auf dem FTP-Speicher einen Ordner auszuwählen für die Infos
MsgBox(0, "_FTP_DirSetCurrent", "Fehler " & @error)
Local $Ordnerstruktur = _FTP_ListToArrayEx ( $verbinde_FTP_Server, 0) ; 0 = Ordner und Dateien / 1 = nur Ordner / 2 = nur Dateien
MsgBox(0, "_FTP_ListToArrayEx", "Fehler " & @error)
For $xx = 1 to $Ordnerstruktur[0][0] ;Schleife zur ermittlichn der vorhandenen Dateien
If $Ordnerstruktur[$xx][2] = 16 Then
$Download_Pfad_Ordner[$ff][0] = $Download_Pfad_Ordner[$x][0] & $Ordnerstruktur[$xx][0] & "/"
$ff = $ff + 1
else
$Download_Pfad_mit_Datei_2[$ss][0] = $Download_Pfad_Ordner[$x][0]
$Download_Pfad_mit_Datei_2[$ss][1] = $Ordnerstruktur[$xx][0]
;MsgBox(0, $Laufwerk, $Download_Pfad_mit_Datei_2[$ss][0] & $Download_Pfad_mit_Datei_2[$ss][1])
$ss = $ss + 1
endif
next
next
;-------------- Sortiert nach gewünschter Reihenfolge ---------------
$xxx = 1
Local $Dateiformat[5]
$Dateiformat[1] = ".xlsm"
$Dateiformat[2] = ".accdb"
$Dateiformat[3] = ".exe"
$Dateiformat[4] = ""
For $xx = 1 to 4
$xxx = $xxx + 1
For $x = 1 to $ss +40
;MsgBox(0, "", StringInStr ( $Download_Pfad_mit_Datei_2[$x][1], ".xlsm" ))
If StringInStr ( $Download_Pfad_mit_Datei_2[$x][1], $Dateiformat[$xx] ) <> 0 or $xx = 4 and $Download_Pfad_mit_Datei_2[$x][1] <> "" Then
$Download_Pfad_mit_Datei[$xxx][0] = $Download_Pfad_mit_Datei_2[$x][0]
$Download_Pfad_mit_Datei[$xxx][1] = $Download_Pfad_mit_Datei_2[$x][1]
$Download_Pfad_mit_Datei_2[$x][1] = ""
$xxx = $xxx + 1
EndIf
Next
Next
;-------------- Erstellt ein Windowsfenster mit den Checkboxen und Buttons ---------------
Local $hGUI = GUICreate("Es stehen " & $ss - 1 & " Dateien zum Download zur Auswahl.", 400, 900) ;erstellt ein Windowsfenster
For $x = 1 to $ss + 40 ;Schleife zur ermittlichn der vorhandenen Ordner
If $Download_Pfad_mit_Datei[$x][1] = "" and $Download_Pfad_mit_Datei[$x + 1][1] = "" Then ExitLoop
If $Download_Pfad_mit_Datei[$x][1] <> "" Then
$Checkbox_ID[$x] = GUICtrlCreateCheckbox($Download_Pfad_mit_Datei[$x][1], 10, 10 + $eee, 380, 25) ;erstellt eine Checkbox
EndIf
$eee = $eee + 25
next
Local $Download = GUICtrlCreateButton("Download", 10, 870, 185, 25) ;Erstellt ein Button
Local $Abbrechen = GUICtrlCreateButton("Abbrechen", 300, 870, 85, 25) ;Erstellt ein Button
GUISetState(@SW_SHOW, $hGUI) ;ende der Windowsfenster-Erstellung
While 1 ;endlosschleife bis Aktion geschied (Button drücken)
Switch GUIGetMsg()
Case $Download ;wenn Download-Button gedrückt
$Download_starten = 1
ExitLoop
Case $GUI_EVENT_CLOSE, $Abbrechen ;wenn Schließ-Button oder Abbrechen-Button gedrückt
$Download_starten = 0
ExitLoop
EndSwitch
WEnd
;----------------- lässt den Download mit den ausgewählten Dateien starten -----------------
If $Download_starten = 1 Then
For $x = 1 to $ss + 11
If GUICtrlRead($Checkbox_ID[$x]) = 1 Then ;prüft, ob Checkbox ausgewählt wurde
Local $FTP_Downloadpfad = $FTP_Pfad & $Download_Pfad_mit_Datei[$x][0]
Local $Speicherpfad_Festplatte = $Festplatte_Pfad & $Download_Pfad_mit_Datei[$x][0]
Local $Downloaddatei = $Download_Pfad_mit_Datei[$x][1]
;----------------- einen neuen Ordner auf der Festplatte erstellen -----------------
Local $aArray = StringSplit ( $Speicherpfad_Festplatte, "/" , 0 ) ;String aufteilen in ein Array
For $www = 2 to $aArray[0]
DirCreate ( $aArray[1] ) ;erstellt den letzten Ordner des Pfades auf der Festplatte
If @error Then MsgBox(0, "_FTP_Connect", "Kein Ordner auf der Festplatte erstellt")
$aArray[1] = $aArray[1] & "/" & $aArray[$www]
Next
;----------------- führt Download aus, wenn Datei vorhanden -----------------
_FTP_ProgressDownload ( $verbinde_FTP_Server, $Speicherpfad_Festplatte & $Downloaddatei, $FTP_Downloadpfad & $Downloaddatei) ;führt Download aus
If @error Then
MsgBox(0, "Info", "Download-Datei """ & $Downloaddatei & """ kann nicht heruntergeladen werden")
Else
MsgBox(0, "Info", "Download-Datei """ & $Downloaddatei & """ wurde heruntergeladen",3)
EndIf
EndIf
next
EndIf
EndIf
Local $iFtpc = _FTP_Close($verbinde_FTP_Server)
Local $iFtpo = _FTP_Close($hOpen)
Alles anzeigen
Ist leider ein sehr langen Code.... ich habe die verschiedenen Arbeitsschritte etwas beschriftet, damit er besser verständlich wird....
Gruß