Table of Contents

GetSnapshots

For downloading the last OpenBSD snapshots.

Required extra tools:

Version 2

@ECHO OFF
REM GetSnapshots.cmd
REM For downloading the last OpenBSD snapshots.
REM 20120713, v1.
REM 20120714, v2.
REM		Removed INSTISO echo's and added an architecture echo.
SETLOCAL ENABLEDELAYEDEXPANSION
SET CURL=D:\Apps\cURL\curl.exe
SET SHA256=D:\Apps\md5deep\sha256deep64.exe
SET ARCHS=i386 amd64 macppc sparc64 hppa alpha loongson
SET FTPUSR=anonymous
SET FTPPWD=passwordoremailaddress
SET INSTISO=
FOR /D %%S IN (%ARCHS%) DO (
	ECHO %%S
	IF NOT EXIST %%S MKDIR %%S
	IF NOT EXIST %%S\SHA256 "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/%%S/SHA256 -o %%S\SHA256
	IF "!INSTISO!" EQU "" (
		FOR /F "tokens=*" %%D IN ('find "install" %%S\SHA256') DO (
			SET INSTISO=%%D
		)
		SET INSTISO=!INSTISO:~8,13!
	)
	IF NOT EXIST %%S\!INSTISO! "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.eu.openbsd.org/pub/OpenBSD/snapshots/%%S/!INSTISO! -o %%S\!INSTISO!
	IF EXIST %%S\!INSTISO! "%SHA256%" -l -w -m %%S\SHA256 %%S\!INSTISO! >> sha256results.txt
)
IF NOT EXIST ports.tar.gz "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.eu.openbsd.org/pub/OpenBSD/snapshots/ports.tar.gz -o ports.tar.gz
IF EXIST ports.tar.gz "%SHA256%" -l ports.tar.gz > ports.tar.gz.sha256

Version 1

@ECHO OFF
REM GetSnapshots.cmd
REM For downloading the last OpenBSD snapshots.
REM 20120713, v1.
SETLOCAL ENABLEDELAYEDEXPANSION
SET CURL=D:\Apps\cURL\curl.exe
SET SHA256=D:\Apps\md5deep\sha256deep64.exe
SET ARCHS=i386 amd64 macppc sparc64 hppa alpha loongson
SET FTPUSR=anonymous
SET FTPPWD=passwordoremailaddress
SET INSTISO=
FOR /D %%S IN (%ARCHS%) DO (
	IF NOT EXIST %%S MKDIR %%S
	IF NOT EXIST %%S\SHA256 "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/%%S/SHA256 -o %%S\SHA256
	IF "!INSTISO!" EQU "" (
		FOR /F "tokens=*" %%D IN ('find "install" %%S\SHA256') DO (
			SET INSTISO=%%D
		)
		ECHO !INSTISO!
		SET INSTISO=!INSTISO:~8,13!
		ECHO !INSTISO!
	)
	IF NOT EXIST %%S\!INSTISO! "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.eu.openbsd.org/pub/OpenBSD/snapshots/%%S/!INSTISO! -o %%S\!INSTISO!
	IF EXIST %%S\!INSTISO! "%SHA256%" -l -w -m %%S\SHA256 %%S\!INSTISO! >> sha256results.txt
)
IF NOT EXIST ports.tar.gz "%CURL%" --remote-time --user %FTPUSR%:%FTPPWD% ftp://ftp.eu.openbsd.org/pub/OpenBSD/snapshots/ports.tar.gz -o ports.tar.gz
IF EXIST ports.tar.gz "%SHA256%" -l ports.tar.gz > ports.tar.gz.sha256

Hints taken from:
stackoverflow - Variable assignment problem in DOS batch file for loop and dostips.com - DOS - Script Snippets for delayed expansion.
dostips.com - DOS - String Manipulation for string mangling.