1.

Solve : Batch File Using Wget?

Answer»

I'm trying to write a basic batch file that will download files from an ftp site that contain a date/time stamp, but I'm having difficulties.

The main part is below. The MODELTIME is a combination of the date and hour variables:

SET MODELTIME=%DATE1%%RUNTIME%
ECHO %MODELTIME%

wget ftp://xxxxxx.com/%MODELTIME%*.GRB


But, this won't work; I'm not sure how to pass the %MODELTIME% variable in the site name.

Thanks in advanceIt is not clear what you want to do or why? Is this just an exercise, or is the a piratical need?

Why use Wget?
http://gnuwin32.sourceforge.net/packages/wget.htm

The standard FTP commands in windows are here:
http://www.nsftools.com/tips/MSFTP.htm

Why not just download all the files in a directory and then select the ones that match the time stamp you want?
BRIAN, you'll need to explain fully and perhaps provide URL info if that is were the issue LIES.

@Geek-9pm: ftp normally uses the system time for downloaded files.

I think brian wants folders that contain a date or time - if they are part of the URL.One of the commands in FTP is to show the current directory. Most SYSTEMS will give time stamps. Here is a picture.

In the above, the name, date and size are shown. Using FTP at the command line should give the same information. But the time is from the date created on the remote computer in the format using by its own system.
But like you said, he needs to clarify what he wants. We were talking about a batch file, not a gui tool though.

And you can't do this because FTP uses the system date and time for creation time.

Quote from: Geek-9pm on January 23, 2013, 05:43:50 PM

Why not just download all the files in a directory and then select the ones that match the time stamp you want?
Thanks for the replies. I could do what Geek suggested and download all files on the FTP site and just KEEP the current files, based on the datestamp, but I'm sure there is an easier way of passing the date/time stamp into the filename.

Foxidrive, you are right that the files from the ftp site have the date/time stamp in their name, so I only wanted to download the current ones. A sample URL is below:

ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2013012400/

So, how can I put the time/date stamp (2013012400) into the wget command:

wget ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.%MODELTIME%/Another approach might be to use WGET to get a file listing of what is in the ftp directory:

Code: [Select]wget ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/

This will produce an index.html file. You could try using batch, but a better solution would be VBScript or Powershell (both available on your machine) to parse the index data and find the most recent files.

Next step would be to use WGET again, this time with specific file names.

Just a thought.


Discussion

No Comment Found