Automatic upload with batch file

Advertisement

ClassicCarr
Joined:
Posts:
3

Automatic upload with batch file

I have created a batch file but it is not uploading to our FTP site. Batch file is such:
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Program Files (x86)\WinSCP\WinSCP.log" /ini=nul ^
  /command ^
    "open ftpes://LOGINID:Password@ftps.xxx.com/" ^
    "lcd ""T:\directory housing files""" ^
    "cd /" ^
    "put test.txt" ^
    "put test2.txt" ^
    "put trial.txt" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%
It will not ftp the files to the site. Obviously I have saved it as a batch file. Also, I have changed the sensitive information above. I would like to do an upload of all files in the directory and delete the files when done.

Any help on the syntax of the batch file? I have winscp installed in the default directory so the path to the program isn't an issue.

Thanks in advance for any assistance.

Reply with quote

Advertisement

ClassicCarr
Joined:
Posts:
3

Powershell command

Or I can get this powershell command to work but I would like to have it upload all files in the directory and then delete the files. Is it as easy and just replacing the file name new test 2.txt with *.* to upload all files in the directory:

# PowerShell >=7.3
$PSNativeCommandArgumentPassing = "Legacy"

& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
/log="C:\install\log\WinSCP.log" /ini=nul `
/command `
"open ftpes://XXX:Password@ftps.XXXX.com/" `
"lcd `"`"T:\Path`"`"" `
"cd /" `
"put -delete `"`"New test 2.txt`"`"" `
"exit"

$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
Write-Host "Success"
}
else
{
Write-Host "Error"
}

exit $winscpResult

Reply with quote

Advertisement

You can post new topics in this forum