Topic "Skip file on error"

Author Message
[View user's profile]

Joined: 2012-11-30
Posts: 1
Location: Keene NH
I have a script which connects to a remote server, then uploads files daily. However, the files are not always created each day, and I need the batch file to continue if the file doesn't exist. Right now, I am getting the following error:


File or folder 'y:\file1.xls' does not exist.
System Error. Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort
Press any key to continue...

Here is the code:

@echo off

net use b: "Location 1"
net use x: "Location 2"
net use y: "Location 3"

set m=%DATE:~4,2%
set d=%DATE:~7,2%
set y=%DATE:~-4%
set y2=%DATE:~-2%

echo option batch abort> b:\ftpcmd.dat
echo option confirm off>> b:\ftpcmd.dat
echo open username:password@ftp.address:22>> b:\ftpcmd.dat
echo put y:\file1.xls /folder/>> b:\ftpcmd.dat
echo put x:\file2.xml /folder/>> b:\ftpcmd.dat
echo put x:\file3.xml /folder/>> b:\ftpcmd.dat
echo put x:\file4.xml /folder/>> b:\ftpcmd.dat
echo exit>> b:\ftpcmd.dat

cd c:\program files\winscp\ /script=b:\ftpcmd.dat

Rem ********* Delete FTP Script File ***********
del b:\ftpcmd.dat

net use b: /DELETE /y >NUL
net use x: /DELETE /y >NUL
net use y: /DELETE /y >NUL


Any suggestions would be appreciated.

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
if exist y:\file1.xls echo put y:\file1.xls /folder/>> b:\ftpcmd.dat


You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License