I am working on a script to automate some file manipulation on an SFTP server which involves downloading files and then moving the originals to an archive folder on the SFTP server. The script needs to run every day. Currently, I have a batch file that calls psftp -b and loads a .txt file with the commands to move the files around. However, the SSH commands that are available are rather limited, and as far as I understand, things like -f, date, etc. are not supported.
The way I have it written now works, but if the script tries to move a file on the SFTP server and there is a file in the destination folder with the same name, it would fail. Granted, I don't know whether this is a likely scenario, but since this is going to run automatically every day without much oversight I'd like to cover all the bases. I'm also just dumping all the files into the archive folder each time, where I would prefer to create folders based on the current yy/mm to organize them better.
Without the full set of SSH commands, I seem to be limited in what I can do with the psftp script, but I can open a putty connection to the SFTP server and enter commands manually, using the full set of SSH commands just fine while logged into the SFTP server. Is there a way to call putty.exe and have the script run SSH commands just like how I can do it manually?