Windows – Controlling psftp in a Windows Batch File


How do I write a batch file to control psftp, but with a dynamic filename? Overall I'm trying to convert a video file and then upload it to my Apple TV. Here's what I have, it generally works, but the commands don't control psftp, psftp just waits for user input:

echo Convert and Upload to Apple TV file Called %1.mkv

ffmpeg -i %1.mkv -vcodec mpeg4 -acodec ac3 -ab 384k -sameq -s hd720 -t 60 %1.avi

psftp frontrow@ -pw aaa
cd downloads/boxee
put %1.avi

I know with the -b flag psftp can call it's own batch file, but I don't know how to get the %1 argument to it. I've seen solutions where a text file is redirected to psftp, but that suffers from the same problem. Also, I'd prefer to have just one file, but having to call a second file would be alright too.

Best Solution

I ended up creating a new batch file from the main one that I then told psftp to use:

echo cd downloads/boxee > psftp.bat
echo put "%1.avi" >> psftp.bat
echo quit >> psftp.bat

psftp frontrow@ -pw aaa -b psftp.bat