Topic "mkdir error if already exists"

Author Message
JohnZT

Guest


Hi prikryl,

I am using winSCP version (5.5.6) in scripting form.
Here is my script:
Code:

#--> This script was created by SQL <--#
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect
open ftp://blablabla/
# Command Line
cd /xxx/extract/
mkdir 201508
cd 201508
rm "XXX_201508*.zip"
put "\\blabla\201508\XXX_201508*.zip"
# Disconnect
close
# Exit WinSCP
exit
#--> EOF This script was created by SQL <--#


And this is my xmllog:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="blabla" start="2015-09-08T13:20:24.578Z">
  <failure>
    <message>Error creating folder '201508'.</message>
    <message>201508: File exists.</message>
  </failure>
  <mkdir>
    <filename value="/xxx/extract//201508" />
    <result success="false">
      <message>201508: File exists.</message>
    </result>
  </mkdir>
</session>


Is there any way I confirm if the folder already exists and bypass mkdir step?

Best regards,

João Silva
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
You can set option batch continue before mkdir to ignore any errors and restore the option batch abort after.

Or use PowerShell script with WinSCP .NET assembly.

See also https://winscp.net/eng/docs/script_checking_file_existence
Guest




Hi again prikryl,

Thank you very much!

Best regards,

João Silva
Guest




It worked for me.
Really good solution!!!
Advertisements

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License