I need to sftp to a remote server, find the latest file on the server, download the file, and rename the file so it's not used again. I have no control over the file naming convention, so I need to retain the name so I can rename it as well. I know how to do this in a shell script. The part I'm having an issue with is how do I do this in a SFTP batch file?

  • 1
    Congratulations, you get to parse ls, since sftp is limited in the command-set it has. – Jeff Schaller Feb 26 at 19:23
  • My best suggestion (without enough experience to make an Answer of it) is to use sshfs so that you can use your local shell/tools to do the work safely. – Jeff Schaller Feb 26 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.