WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

FTP Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to ftp a File and Make Today's Date File Rename

Keywords:     TimeJulianDay

Question:

Does anybody have any idea on how I can download a weekly file from an ftp site where the filename changes every week based on the current date?

For example:

This week monday was Nov 17; so the filename would be 1117.exe.

Is there a way to get the date somehow from windows and import that into the filename and then use netscape to download the file?

Answer:

  1. Use the Internet Extender to download the file for you.

  2. Part of the trick is figuring out the filename you want.
    ;Get date in Julian format
    Today=TimeYmdHms()
    TodayJulian=TimeJulianDay(Today)
    
    ;Figure out day of week
    Day=(TodayJulian+5) mod 7
    ;0=Sunday 1=Mon 6=Sat
    
    ;Adjust day number to days
    ;from Monday
    DaysFromMonday=(Day+6) mod 7
    
    MondayJulian=TodayJulian - DaysFromMonday
    
    Monday=TimeJulToYmd(MondayJulian)
    
    monthnum=ItemExtract(2,Monday,":")
    daynum=ItemExtract(3,Monday,":")
    myfilename=strcat(monthnum,daynum,".exe")
    Message("Monday's Filename is",myfilename)
    

Article ID:   W12647
Filename:   How to FTP a File and Rename it with Todays Date.txt
File Created: 1999:04:15:16:48:40
Last Updated: 1999:04:15:16:48:40