Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

FTP download Tool


  • Please log in to reply
1 reply to this topic
Nuwan
  • Members
  • 32 posts
  • Last active: Jun 24 2015 04:46 AM
  • Joined: 08 Oct 2005

This Tool for Download FTP server file to given path in given time repeatedly, also file name can modify by incrementally.

Gui enable to input FTP Server IP/login/path in local directory and Downloading time.

;2013-05-21  Nuwan :FTP Download to external path 
;----------------------------------------------------------------------------- 
;FTP folder is WorkingDirectory (Place where the compiled exe file located)
;----------------------------------------------------------------------------- 
server := "192.168.196.150"
username := "data"
password := "test"
remoteSubDir := "/test" ; optional
Pathfile := A_WorkingDir
CN:=A_Now 
StringMid,YMD,CN,1,8 
Filename=HW_EXPORT_1_%YMD%.ZIP
;================================
	Gui, 1:font, cRed wBold s12,Times New Roman 
	Gui, 1:Add, Text,vMyText, 
	Gui, 1:Add, Text, x20 y120 w240 h20,File path is WorkingDirectory
	Gui, 1:font, cBlack s10
	Gui, 1:Add, Text, x10 y10 w100 h20, FTP server IP
	Gui, 1:Add, edit,vserver x90 y9 w110 h20,%server%
	Gui, 1:Add, Text, x10 y30 w100 h20, User
	Gui, 1:Add, edit,vusername x40 y30 w80 h20,%username%
	Gui, 1:Add, Text, x138 y30 w100 h20, PW
	Gui, 1:Add, edit,vpassword x160 y30 w80 h20,%password%
	Gui, 1:Add, Text, x10 y50 w100 h20, Time           :
	Gui, 1:Add, edit,vTme1 x40 y50 w30 h18,04
	Gui, 1:Add, edit,vTme2 x76 y50 w30 h18,00
    Gui, 1:Add, Text, x10 y70 w100 h20, Filename is   @
	Gui, 1:Add, edit,vPathfile x95 y68 w165 h20,%Pathfile%
	Gui, 1:Add, edit,vFname x10 y90 w200 h25,%Filename%
      Gui, 1:font, wBold s10
	  Gui, 1:Add, Button, x50 y150 w80 h40 gstt, Start
      Gui, 1:Add, Button, x150 y150 w80 h40 gext, Exit
	  Gui, 1:Color,vGcol,
	  Gui, 1:Color,99AABB
      Gui, 1:-Border -Caption +ToolWindow 
      Xp:= A_SCREENWidth - 300 
      Yp:= A_SCREENHeight - 300
      Gui, 1:Show,x%XP% y%Yp% ,FtpTool
	  WinSet, AlwaysOnTop, on,FtpTool
	  SetTimer,clock,1000
Return
ext:
{
ExitApp 
}

clock:
{
CM:=A_Now 
GuiControlGet, Tme1
GuiControlGet, Tme2
  StringMid,TM,CM,9,4
  StringMid,SN,CM,13,2
if TM=%Tme1%%Tme2%
 { if SN=00
	{
GuiControlGet, Fname
GuiControlGet, server
GuiControlGet, username
GuiControlGet, password
GuiControlGet, Pathfile
fGet(Fname)
	}
 }
}
Return

stt:
{
GuiControlGet, Fname
GuiControlGet, server
GuiControlGet, username
GuiControlGet, password
GuiControlGet, Pathfile
fGet(Fname)
}
Return
;================================
; Get FTP File
fGet(ftpFile)
	{
	global server
	global username
	global password
	global remoteSubDir
	global YMD
	global Filename
	global Pathfile
	ahkMessage := "Downloading """ ftpFile """"
	sLog(ahkMessage)
	
	;
	; ----- Prepare BAT File -----
	;
	baseName := "FTP_Auto_Download"
	batFile := baseName ".bat"
	scrFile := baseName ".scr"
	FileDelete, %batFile% ; Attempt to delete leftover files
	FileDelete, %scrFile% ; Attempt to delete leftover files
	
	FileAppend, ftp -s:%scrFile%`n, %batFile%
	
	;
	; ----- Prepare SCR File -----
	;
    scrOutput := ""
    scrOutput := scrOutput "open " server "`n"            ; Open connection to our ftp server.
    scrOutput := scrOutput username "`n"                ; Enter user name.
    scrOutput := scrOutput password "`n"                ; Enter password.
    scrOutput := scrOutput "hash`n"                        ; Turn on hash marks.
;    scrOutput := scrOutput "cd " remoteSubDir "`n"        ; Enter sub-directory. (optional)
    scrOutput := scrOutput "get " ftpFile "`n"            ; Download the remote file.
;    scrOutput := scrOutput "delete " ftpFile "`n"        ; Delete the remote file.
    scrOutput := scrOutput "bye`n"                        ; Close ftp connection.
    FileAppend, %scrOutput%, %scrFile%

	Sleep, 500
	
	;
	; ----- Download Files -----
	;
	RunWait, %batFile%, , Min
	FileDelete, %batFile%
	FileDelete, %scrFile%
	
IfExist, %Pathfile%\%ftpFile%
{
YMD += 1, days
StringMid,YMD,YMD,1,8 
Filename=HW_EXPORT_1_%YMD%.ZIP
GuiControl,, Fname, %Filename%
	ahkMessage := "Downloading complete."
	sLog(ahkMessage)
Gui, 2:font, cWhite wBold s12,Times New Roman
Gui, 2:Add, Text, x10 y5 w250 h55,"%ftpFile%" FTP Completed
Gui, 2:font, cYellow s10
Gui, 2:Add, Text, x10 y65 w150 h15, Next Schedule file is
Gui, 2:Color,550055
Gui, 2:-Border -Caption +ToolWindow 
Xp:= A_SCREENWidth - 300 
Yp:= A_SCREENHeight - 300
Gui, 2:Show,x%XP% y%Yp% ,Banner
WinSet, AlwaysOnTop, on,Banner
}
else
{
;YMD += 1, days
;StringMid,YMD,YMD,1,8 
Filename=HW_EXPORT_1_%YMD%.ZIP
GuiControl,, Fname, %Filename%
	ahkMessage := "Downloading Error. Path "Pathfile
	sLog(ahkMessage)
Gui, 2:font, cWhite wBold s12,Times New Roman
Gui, 2:Add, Text, x10 y5 w250 h55,FTP Error, "%ftpFile%" 
Gui, 2:font, cYellow s10
Gui, 2:Add, Text, x10 y65 w150 h15, Next Schedule file is
Gui, 2:Color,AA0022
Gui, 2:-Border -Caption +ToolWindow 
Xp:= A_SCREENWidth - 300 
Yp:= A_SCREENHeight - 300
Gui, 2:Show,x%XP% y%Yp% ,Banner
WinSet, AlwaysOnTop, on,Banner
}
	}

; Summary Log - Appending
AppendLog(ahkMessage) 
	{
	len := StrLen(A_ScriptName)
	nameTemp := SubStr(A_ScriptName, 1, len - 4)
	FileAppend, %ahkMessage%, %A_WorkingDir%\%nameTemp%_Log.txt
	}

; Summary Log - Formatting
sLog(ahkMessage) 
	{
	FormatTime, LogTimeString, , yyyyMMdd hh:mm:ss tt ; "20081230 11:14:24 AM"
	ahkMessage := LogTimeString " " ahkMessage "`n"
	AppendLog(ahkMessage)
	}






aemccoo
  • Members
  • 5 posts
  • Last active: Jul 14 2015 01:56 PM
  • Joined: 02 Dec 2013

hi nuwan, im very interested developing the tool , i dont know anything about coding, i only use PulOver's macro creator

please help me build up mine from scratch thx, or anyone if there is anyone who happens to passby, im only using the macro creator tool

with the builtin functions on it 

 

heres what ive practiced so far 

1469833_561769697240464_1379432733_n.jpg