Skip to content

Instantly share code, notes, and snippets.

@maphew
Created December 3, 2015 19:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maphew/0f2f1b4f3659440bae82 to your computer and use it in GitHub Desktop.
Save maphew/0f2f1b4f3659440bae82 to your computer and use it in GitHub Desktop.
Download National Hydrographic Network for Yukon Territory and surround
@echo off
:: rev 0.1 2008.Mar.10, Matt.Wilkie@gov.yk.ca
:: rev 0.2 2008.Sept.18 - updated to account for change in ftp source folders
:: rev 0.3 2014.Feb.06 - enable timestamp (only download if source newer)
echo.
echo. -----------------------------------------------------------------------
echo. Going to download National Hydrographic Network Yukon, which could take
echo. awhile. This script can be aborted and rerun, it will resume
echo. where it left off.
echo. -----------------------------------------------------------------------
ping -n 6 localhost >nul
setlocal
:: Ensure we download next to this script, in case of being started from UNC path.
pushd %~dp0
echo. Saving files to %~dp0 (as %cd%)
call :ChkReqs wget.exe
popd
goto :EOF
:ChkReqs
:: test for wget, if it is in path we can carry on.
if exist "%~$PATH:1" (
call :Download ) else (
echo %1 not found! can't continue
)
goto :End
:Download
set urlRoot=ftp://ftp2.cits.rncan.gc.ca/pub/geobase/official/nhn_rhn/gdb_en/
:: Change these region numbers as required for your area of interest
:: http://www.geobase.ca/geobase/en/find.do?produit=nhn
set QuadList=09 10 08
:: Change 'gdb' to 'shp' if that is your prefence; 'en' to 'fr' pour francais
:: 'wait' options are to take it easy on the host server.
set opts=--random-wait --wait 1 --accept *gdb_en.zip --no-verbose --recursive --continue --timestamping
for %%a in (%QuadList%) do (
wget --level=3 --no-host-directories --cut-dirs=4 %opts% %urlRoot%/%%a
)
goto :End
:End
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment