Batch file to upload files created today

Advertisement

natchiram
Joined:
Posts:
8

Batch file to upload files created today

Hi, I am trying to put a file into a remote location and delete it after the upload process completes. It is failing with this error
(ExtException) **Copying files to remote side failed.**
I have attached the log file.

The script that I am using is as below:
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\WinSCP\WinSCP.log" /rawconfig Logging\LogFileAppend=0 /ini=nul /command ^
    "open ftp://username:password@ip address:port/" ^
    "cd /remote directory" ^
    "lcd ""local directory""" ^
    "put -filemask=*>=today ""Local directory\*"" -delete" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%
Regards,
Ram

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,285
Location:
Prague, Czechia

Re: Batch file to upload files created today

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

natchiram
Joined:
Posts:
8

I am not able to see the folders from any of the FTP clients but can navigate to that folder using the credentials in the Windows Explorer. Also, I can transfer the file manually using a simple cmd line script as below, but there are some conditions that I need to add, such as file size, date of creation, which is why I am using WinSCP.
Drive:
cd\path
ftp
OPEN host port
username
password
cd remote location
PUT filename
CLOSE
QUIT

Reply with quote

Advertisement

natchiram
Joined:
Posts:
8

Sorry for the delay. After adding the switch -passive=off, the script worked fine.
Thank you very much for your help.

The modified script is as below:
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\WinSCP\WinSCP.log" /rawconfig Logging\LogFileAppend=0 /ini=nul /command ^
    "open ftp://username:password@ip address:port/ -passive=off" ^
    "cd /remote directory" ^
    "lcd ""local directory""" ^
    "put -filemask=*>=today ""Local directory\*"" -delete" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Reply with quote

dipesht@...
Guest

Batch file error

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\WinSCP\WinSCP.log" /rawconfig Logging\LogFileAppend=0 /ini=nul /command ^
    "open ftp://username:password@ip address:port/ -passive=off" ^
    "cd /remote directory" ^
    "lcd ""local directory""" ^
    "put -filemask=*>=today ""Local directory\*"" -delete" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Reply with quote

Advertisement

You can post new topics in this forum