First draft of batch upload program - not yet tested after extraction of constants into parameters