File Transfer Help

born2achieve

New member
Local time
2:57 PM
Messages
36
hi,

I have two FTP servers namely SampleFTP1(public FTP) and SampleFTP2 (private FTP)

Both are SFTP enabled. Lets take an example, I need to copy the text file from SampleFTP1 path C:/TestData/Test.txt and wanted to transfer to SampleFTP2 path /InputFile/Test.txt. Right now i am suing filezilla to do this as manual process. Is there any where i can automate this process by using batch script. Any example will be very helpful for me to proceed. please help me on this
 

My Computer

Computer type
PC/Desktop
OS
windows7 64 bit
Hey there,

FTP-ing can be done in batch.

Here's some sample script,

Code:
@echo off

REM Paths and file names may or may not be case sensitive!

set server_1_to_connect_to=[COLOR="Red"]11.11.11.11[/COLOR]
set Username=[COLOR="red"]Username[/COLOR]
set Password=[COLOR="red"]Password[/COLOR]
set server_1_path=[COLOR="red"]/TestData[/COLOR]
set file_to_download=[COLOR="red"]Test.txt[/COLOR]

set server_2_to_connect_to=[COLOR="red"]22.22.22.22[/COLOR]
set Username=[COLOR="red"]Username[/COLOR]
set Password=[COLOR="red"][COLOR="red"]Password[/COLOR][/COLOR]
set server_2_path=[COLOR="red"]/InputFile[/COLOR]
set file_to_upload=%FILE_TO_DOWNLOAD%
::
set local_path=%TEMP%

::: Download %server_1_path%/%file_to_download% to %local_path%
	(
		echo.%USERNAME%
		echo.%PASSWORD%
		echo.lcd %TEMP%
		echo.cd %SERVER_1_PATH%
		echo.binary
		echo.get %FILE_TO_DOWNLOAD%
		echo.bye
	) > "%TEMP%\_%~n0.ftp"
	ftp -s:"%TEMP%\_%~n0.ftp" %SERVER_1_TO_CONNECT_TO%
	del "%TEMP%\_%~n0.ftp"
:::

::: Upload %local_path%\%file_to_upload% to %server_2_path%
	(
		echo.%USERNAME%
		echo.%PASSWORD%
		echo.lcd %TEMP%
		echo.cd %SERVER_2_PATH%
		echo.binary
		echo.put %SERVER_FILE_TO_DOWNLOAD%
		echo.bye
	) > "%TEMP%\_%~n0.ftp"
	ftp -s:"%TEMP%\_%~n0.ftp" %SERVER_2_TO_CONNECT_TO%
	del "%TEMP%\_%~n0.ftp"
:::

del %LOCAL_PATH%\%SERVER_FILE_TO_DOWNLOAD%

It may take some fiddling around with to get it to work.
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top