Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP LATEST FILE IN A DIRECTORY

Status
Not open for further replies.

Volkmaniac

Technical User
Mar 19, 2003
104
US
here's a script that will grab the newest file in a specified directory and then ftp it from local to remote:

;****************************************************************************
;* Transfer *
;* This procedure will ftp the zipped batch file to ACT *
;****************************************************************************

proc Transfer

FTP LOCAL CHDIR "XXXX" ;Set the local dir.
while $ftpstatus ;Loop while connecting to FTP site.
yield
endwhile
pause 1 ;Let Procomm update its screen.

Connect FTP "XXXX" ;Connect to ACT FTP site.
FTP REMOTE CHDIR "XXXX" ;Change dir on FTP to remote site.
set ftp filter local "*.zip"



pause 1
sendvkey 0x74
pause 5


GetNewest()


FTP LOCAL COPYFILE fname ;Copy (download) * from FTP
;site to local machine. Filenames
;are case-sensitive!
while $ftpstatus ;Yield while transferring file.
yield
endwhile
pause 10



pwmode TERMINAL
disconnect





endproc


;****************************************************************************
;* GetNewest *
;* This procedure gets the latest file in the specified directory *
;* Calls: None *
;* Modifies Globals: fname *
;****************************************************************************

proc GetNewest


long Newest ;Maintain date/time for newest file found
Fname = "[ None ]" ;Default to [ None ] for name
if findfirst SearchString ;Find the first file
Newest = $FLTIME ;Get the first file's date/time info
Fname = $FILENAME ;Get the first file's name
while findnext ;Find the next file
if $FLTIME >= Newest ;Is this ones date/time newer?
Newest = $FLTIME ;Get the new file's date/time info
Fname = $FILENAME ;Get the new file's file name
endif
endwhile
endif

endproc











































































































 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top