# Batch file to upload files created today

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 ^
"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

martin
Joined:
Posts:
36,265
Location:
Prague, Czechia

## Re: Batch file to upload files created today

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.

natchiram
Hi, Thanks for your response. The full log file that got generated was attached to the original post.

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
cd remote location
PUT filename
CLOSE
QUIT

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 ^
"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%

You can post new topics in this forum