{"id":206,"date":"2019-03-15T17:09:15","date_gmt":"2019-03-15T16:09:15","guid":{"rendered":"https:\/\/leeryanrs.com\/?p=206"},"modified":"2019-03-15T17:09:15","modified_gmt":"2019-03-15T16:09:15","slug":"sftp-automatic-using-winscp","status":"publish","type":"post","link":"https:\/\/leeryanrs.com\/?p=206","title":{"rendered":"SFTP Automatic using winSCP"},"content":{"rendered":"\n<p><br><\/p>\n\n\n\n<p>This script is partially generated from WinSCP automation, however has been modified to put two files onto the remote server with a timestamp and remove any files which are over 14 Days old in that specific remote directory.  <\/p>\n\n\n\n<p><strong>Please note that the SSH-RSA key has to be changed to match your host being accessed by winscp.<\/strong> <\/p>\n\n\n\n<p> @echo off <br>&#8220;C:\\Program Files (x86)\\WinSCP\\WinSCP.com&#8221; ^<br>   \/command ^<br>     &#8220;open sftp:\/\/YOURUSERNAME:YOURPASSWORD@sftp.fairsail.com\/ -hostkey=&#8221;&#8221;ssh-rsa 2048 X7f9U4Io2IKF8G\/m\/OenvXvkDGuMGm0PI5b0\/BGOpRM=&#8221;&#8221; -rawsettings FSProtocol=2&#8243; ^<br>     &#8220;lcd &#8220;&#8221;E:\\YOURFOLDER&#8221;&#8221;&#8221; ^<br>     &#8220;cd \/REMOTEFOLDER&#8221; ^<br>     &#8220;put &#8220;&#8221;FILE1.csv&#8221;&#8221; &#8220;&#8221;FILE1%%TIMESTAMP#yyyymmdd%%.csv&#8221;&#8221; &#8221; ^<br>     &#8220;put &#8220;&#8221;FILE2.csv&#8221;&#8221; &#8220;&#8221;FILE2%%TIMESTAMP#yyyymmdd%%.csv&#8221;&#8221; &#8221; ^<br>     &#8220;rm *&lt;14D &#8221; ^<br>     &#8220;exit&#8221;<br><br> <br>set WINSCP_RESULT=%ERRORLEVEL%<br> if %WINSCP_RESULT% equ 0 (<br>   echo Success<br> ) else (<br>   echo Error<br> ) <br><br> exit \/b %WINSCP_RESULT% <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script is partially generated from WinSCP automation, however has been modified to put two files onto the remote server with a timestamp and remove any files which are over 14 Days old in that specific remote directory. Please note that the SSH-RSA key has to be changed to match your host being accessed by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[24,42,43,51],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-automation","tag-scp","tag-script","tag-windows"],"_links":{"self":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=206"}],"version-history":[{"count":0,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions"}],"wp:attachment":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}