@echo off @REM This Windows XP Batch file harvests today's AmericaView MODIS subset imagery @REM from WisconsinView/SSEC. Modify variables as needed. If you want to run @REM this file in an automated way, consider running the this file with @REM the scheduler (WinXP). To do this go to "Start/All Programs/ @REM Accessories/System Tools/Schedule Tasks/" Double-Click "Add Scheduled @REM Task" to start the Wizard and follow the instructions. Depending on @REM your geographical location, I recommend running this bat file every day @REM several times between noon (east coast) and 8pm (west coast). It depends @REM in part on how "near real-time" you want to be. More detailed instructions @REM on setting up the scheduler are available in a PDF file here: @REM http://www.wisconsinview.org/documents/auto_ftp_winxp_howto.pdf @REM @REM This script was written by Sam Batzli for use by AmericaView StateView @REM members and is free for distribution and modification. @REM ############################################################################ @REM ftp_MODIS_v1.1.bat @REM v.1.0 March 17, 2009 (basic download) @REM v.1.1 March 22, 2009 (added folder hierarchy (yyyy\yyyyddd) SET hostname=ftp.ssec.wisc.edu SET login=anonymous SET password=your_email@university.edu @REM modify to your e-mail SET method=mget SET product=*AV_NE* @REM modify to select StateView product SET basedir=C:\temp @REM modify to where you want the imagery to go SET platform1=terra SET platform2=aqua SET sensor=modis @REM We need to parse the local computer date to build the current @REM MODIS directory structure. Unfortunately, MS-DOS does not @REM provide a three digit day-of-year so we have to construct it. FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B SET date_path=%yyyy%_%mm%_%dd%_ SET leap=0 IF %yyyy% == 2012 SET leap=1 IF %yyyy% == 2016 SET leap=1 IF %yyyy% == 2020 SET leap=1 IF %yyyy% == 2024 SET leap=1 IF %mm% == 01 SET yearday=%dd% IF %mm% == 02 SET /a yearday=31+%dd% IF %mm% == 03 SET /a yearday=59+%dd%+%leap% IF %mm% == 04 SET /a yearday=90+%dd%+%leap% IF %mm% == 05 SET /a yearday=120+%dd%+%leap% IF %mm% == 06 SET /a yearday=151+%dd%+%leap% IF %mm% == 07 SET /a yearday=181+%dd%+%leap% IF %mm% == 08 SET /a yearday=212+%dd%+%leap% IF %mm% == 09 SET /a yearday=243+%dd%+%leap% IF %mm% == 10 SET /a yearday=273+%dd%+%leap% IF %mm% == 11 SET /a yearday=304+%dd%+%leap% IF %mm% == 12 SET /a yearday=334+%dd%+%leap% IF %yearday% LSS 100 SET yd=0%yearday% IF %yearday% LSS 10 SET yd=00%yearday% SET remotedir1=/pub/eosdb/%platform1%/%sensor%/%date_path%%yd%/subsets SET remotedir2=/pub/eosdb/%platform2%/%sensor%/%date_path%%yd%/subsets @REM make year and day subfolders for storing downloads cd %basedir% IF NOT EXIST %yyyy% md %yyyy% cd %yyyy% IF NOT EXIST %yyyy%%yd% md %yyyy%%yd% cd %yyyy%%yd% SET localdir=%basedir%%yyyy%%yd% @REM this creates a file called ftp.txt that is used for ftp @REM it will overwrite any existing file of the same name. echo %login%>ftp.txt echo %password%>>ftp.txt echo lcd %localdir%>>ftp.txt echo cd %remotedir1%>>ftp.txt echo binary>>ftp.txt echo mget %product%>>ftp.txt echo cd %remotedir2%>>ftp.txt echo mget %product%>>ftp.txt echo close>>ftp.txt echo bye>>ftp.txt @REM An ftp.log file is created for viewing the results. @REM Existing files of the same name will be overwritten. echo Attempting download for %date_path%%yd%>ftp.log ftp -is:ftp.txt %hostname%>>ftp.log echo Download attempt complete>>ftp.log