Create a directory or skip though ftp script

I connected to my Adrive.com account to download the backup file. I do not know the version of Linux that is installed. I tried to get a version with these commands:

ftp> uname -r
Invalid command.
ftp> cat /etc/*-release
Invalid command.
ftp> lsb_release -a
Invalid command.
ftp> cat /proc/version
Invalid command.
ftp> uname -a
Invalid command.

As you can see, none of them worked.

Here is my script that I am trying to run:

ECHO open ftp://xxx:xxxx@ftp.adrive.com>FTPSND.TXT
echo cd backup>>FTPSND.TXT
echo cd companyfiles>>FTPSND.TXT
echo mkdir %3>>FTPSND.TXT
echo cd %3>>FTPSND.TXT
echo option transfer binary>>FTPSND.TXT
ECHO send %1>>FTPSND.TXT
ECHO close>>FTPSND.TXT
ECHO exit>>FTPSND.TXT
winscp.com /script=ftpsnd.txt >>%2

And the error that occurs on mkdir:

Error creating folder 'BEL'.
File or directory already exists.
(A)bort, (R)etry, (S)kip: Abort

My main problem is that if the directory does not exist, I need to create it, otherwise I will skip this step and proceed to send.

Any ideas how I get around this?

EDIT

In response to Hackoo:

I did not mention that this batch file is being called from another batch file near the end. When I used your code, I do not upload the file and the log shows:

ftp> Open ftp.adrive.com
Connected to ftp.adrive.com.
220 Username is your email address used for web interface
User (ftp.adrive.com:(none)):
331 Username OK, please send password.

230 Welcome xxxxx
ftp> prompt n
Interactive mode Off .
ftp> bin
200 TYPE changed to I.
ftp> MkDir /backup/companyfiles/IFC
550 File or directory already exists.
ftp> cd /backup/companyfiles/IFC
250 Changed directory OK.
ftp> mput D:\SSSAVES\sssbackup\TMPDIR\IFC_20160705141154.ZIP
200 PORT command OK.
150 Opening BINARY mode data connection for file IFC_20160705141154.ZIP.

. 2 , . 70 , , .

№ 2

Adrive, , ftp mput . , .

№ 3

mput put, 1 . .

+4
2

ADrive.com, script,

@echo off
Title Multiple file Upload by Hackoo on adrive
Color 0A
::****** Settings for FTP ************
Set FTPSERVER=ftp.adrive.com
Set USER=Your Login
Set Password=Your Password
Set LocalFolder=C:\Hackoo
Set RemoteFolder=/backupFolder
::************************************
::--- FTP commands below here ---
> ft.do echo Open %FTPSERVER%
>> ft.do echo %USER%
>> ft.do echo %Password%
>> ft.do echo prompt n
>> ft.do echo bin
>> ft.do echo lcd %LocalFolder%
>> ft.do echo MkDir %RemoteFolder%
>> ft.do echo cd %RemoteFolder%
>> ft.do echo mput "*.*"
>> ft.do echo disconnect
>> ft.do echo bye
::************************************
ftp -s:ft.do
del ft.do
Pause
+1

vbscript , 70 :

set objShell = CreateObject("WScript.Shell")
Login = "Your Username"
'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
Login = Replace(Login,"@","+")
Password = "Your Pass"
FTPSERVER = "ftp.server.com"
RemoteFolder = "RemoteFolderName"
FTPURL = "ftp://"& Login &":"& Password &"@"& FTPSERVER &"/"& RemoteFolder
Connect2FTP = objShell.run("Explorer "& FTPURL ,1,False)

vbscript,

:

, , , -? , , FTP-? , , FTP- (FileZilla, CuteFTP, FlashFXP ..) FTP-! = > FTP Explorer - - Windows FTP-!

!

, !

enter image description here

Titre = "FTP EXPLORER © Hackoo © 2016"
    Set objIE = CreateObject( "InternetExplorer.Application" )
    objIE.Navigate "about:blank"
    objIE.Document.Title = Titre
    objIE.ToolBar        = False
    objIE.Resizable      = False
    objIE.StatusBar      = False
    objIE.Width          = 320
    objIE.Height         = 390
    ScreenWidth = objIE.document.ParentWindow.screen.width 
    ScreenHeight = objIE.document.ParentWindow.screen.height
    objIE.Left = (ScreenWidth  - objIE.Width ) \ 2
    objIE.Top  = (ScreenHeight - objIE.Height) \ 2
    Do While objIE.Busy
        WScript.Sleep 200
    Loop
    objIE.Document.Body.InnerHTML = "<div align=""center""><p><h3 style='color:Red'>UserName " _
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""Login"" value=""put your user name here""></h3></p>"_
    & "</p><p><h3 style='color:Red'>Password<br><input type=""password"" style='color:Blue' value=""Put your password here"" size=""20"" " _
    & "id=""Password""></h3></p><p><input type=" _
    & """hidden"" id=""OK"" name=""OK"" value=""0"">" _
    & "<h3 style='color:Red'>FTP Server " _
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""FTPSERVER"" value=""ftp.server.com""></h3>"_
    & "<br><h3 style='color:Red'>Remote Folder "_
    & "<br><input type=""text"" style='color:Blue' size=""20"" " _
    & "id=""DossierDistant"" value=""/www""></h3></p>"_
    & "<input type=""submit"" value="" Browse your FTP Folder"" " _
    & "onclick=""VBScript:OK.Value=1""></p></div>"
    objIE.Document.Body.Style.overflow = "auto"
    objIE.Document.body.style.backgroundcolor="lightGreen"
    objIE.Visible = True
    objIE.Document.All.Password.Focus
    On Error Resume Next
    Do While objIE.Document.All.OK.Value = 0
        WScript.Sleep 200
        If Err Then    
            IELogin = Array( "", "" )
            objIE.Quit
            Set objIE = Nothing
            wscript.quit
        End if
    Loop
    On Error Goto 0
    Set ws = CreateObject("wscript.Shell")
    Login = objIE.Document.All.Login.Value
    Login = Replace(Login,"@","+")'If your username contains the @ symbol, and your web browser does not support this, you can substitute for the +
    Password = objIE.Document.All.Password.Value
    FTPSERVER = objIE.Document.All.FTPSERVER.Value
    DossierDistant = objIE.Document.All.DossierDistant.Value
    URL = "ftp://"&Login&":"&Password&"@"&FTPSERVER&"/"&DossierDistant
    Connect2FTP = ws.run("Explorer "& URL ,1,False)
    objIE.Quit
ws.Popup "Connecting to "&qq(FTPSERVER)&" is in progress ..........",3,"Connecting to "&qq(FTPSERVER)&" is in progress ..........",64
    Set objIE = Nothing
    Set ws = Nothing
    Close("iexplore.exe")
'****************************************************
Sub Close(Process)
    Set Ws = CreateObject("Wscript.Shell")
    Command = "cmd /c Taskkill /F /IM "&Process&""
    Execution = Ws.Run(Command,0,True)
End Sub
'****************************************************
Function qq(strIn) 
    qq = Chr(34) & strIn & Chr(34)
End Function
'****************************************************
0

All Articles