• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

command line to upload with ncftp

I can successfully upload with ncftpput.exe, via:
ncftpput.exe -u "user" -p "pass" "ftp.domain.com"  "/access_db/" "c:\lock folder\lock.txt"

Open in new window

but I need to upload multiple files and rename those files.
is it possible to use ncftpput.exe without creating multiple connections and/or change the filename on the ftp server?  Or is there an easier way with ncftp.exe
0
Knightsman
Asked:
Knightsman
  • 3
2 Solutions
 
Bill PrewCommented:
Are all the files heading to the same directory on the destination FTP server?  If so, then the easiest way might be to rename them on the PC and then send them all up at once from a staging folder.  NCFTPPUT does not support renaming as far as I know, and NCFTP.EXE is not command line friendly.

If you really need more control you might want to consider a different FTP client that has better script / automation support.

~bp
0
 
KnightsmanAuthor Commented:
Want to finish up this question for those that need it.
I ended up going with WinSCP

Transfer file:
"put ""c:\Program Files (x86)\Common Files\folder\lock.txt"" /access_db/ " ^

Open in new window


Delete file:
"rm /access_db/lock.txt" ^

Open in new window


Rename file:
 "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register2.mdb" ^

Open in new window


This is the full code, you will need to use WinSCP.com instead of the .exe for batch files.
@echo off
"C:\Program Files (x86)\Common Files\folder\WinSCP.com" ^
  /log="WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://username:password@ftp.domain.com/" ^
    "put ""c:\Program Files (x86)\Common Files\folder\lock.txt"" /access_db/ " ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register.mdb" ^
    "rm /access_db/lock.txt" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register2.mdb" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register3.mdb" ^
    "put ""c:\Program Files (x86)\Common Files\folder\register.mdb"" /access_db/register4.mdb" ^

    "exit"
	

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Open in new window

1
 
KnightsmanAuthor Commented:
updated
0
 
KnightsmanAuthor Commented:
Wanted points to go to Bill for the idea to switch Programs.  But wasn't file solution, wasn't sure how to finalize.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now