jesobreira

FTP download entire folder

May 19th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.86 KB | None | 0 0
  1. #include <FTPEx.au3>
  2.  
  3. Global $sFolder = "C:\pasta" ; salvar aqui
  4.  
  5. ; se quiser que a pasta tenha a data, faça:
  6. ; Global $sFolder = "C:\" & @YEAR & "-" & @MON & "-" & @MDAY
  7. ; DirCreate($sFolder)
  8.  
  9.  
  10. Global $sRemotePath = "/logs" ; pasta no FTP
  11.  
  12. ; abre um cliente FTP com um user agent qualquer
  13. $hOpen = _FTP_Open("HUE BR FTP Client")
  14.  
  15. ; Conectar ao svr
  16. $hConn = _FTP_Connect($hOpen, 'servidor', 'usuario', 'senha')
  17.  
  18. ; Entrar na pasta
  19. _FTP_DirSetCurrent($hConn, $sRemotePath)
  20.  
  21. ; Gerar um array com a lista de arquivos
  22. ; Os arquivos começam no index 1, mas o index 0 tem a quantidade de arquivos encontrados
  23. $aList = _FTP_ListToArray2D($hConn)
  24.  
  25. ; Loop de 1 até (arquivos encontrados)
  26. For $i = 1 To $aList[0][0]
  27.     ; Baixa o arquivo
  28.     _FTP_FileGet($hConn, $aList[$i][0], $sRemotePath & "\" & $aList[$i][0])
  29. Next
  30.  
  31. ; Fecha a conexão
  32. _FTP_Close($hConn)
Add Comment
Please, Sign In to add comment