I adopted a legacy log shipping setup that was sent over sftp using a combination of SSIS, putty, Sqb2mtf, a series of stored procs, and several configuration/logging tables.
It was mostly broken when I inherited it and spent a good amount of time getting it working and performing well considering the vendor and our internal requirements.
Sorry I don't have any code handy, but I can highly recommend Bitvise Tunnelier vs any of the other sftp options I tested. It's easily scripted and about as fast as sftp gets for Windows.
Why not handle the variables in T-sql, powershell,vb , pearl or python?