Solved auto copy .txt file on ftp

July 29, 2016 at 01:52:06
Specs: Windows 64
I need a batch that can automatic copy a .txt file from a local computer to a ftp.
It needs to run every day and overwrite the old .txt file with the same name.
Can anyone help me ?

See More: auto copy .txt file on ftp

Reply ↓  Report •


✔ Best Answer
August 8, 2016 at 20:49:01
Make a new directory and put this bat there.
Run it and take note of whether the COPY worked.
And, yeh, it will create an ft.txt file.


::====================================================================
@echo off > ft.txt
copy "C:\Users\user001\Desktop\New folder\Test.txt"
echo if you don't see:
echo 1 file(s) copied
echo your file isn't where you think and you need to find it
pause

>> ft.txt echo o ftp.totalpartsplus.com
>> ft.txt echo user001
>> ft.txt echo abcd1234
>> ft.txt echo bin
>> ft.txt echo prompt
>> ft.txt echo CD abc/newfolder
>> ft.txt echo put Test.txt
>> ft.txt echo bye

ftp -s:ft.txt

=====================

=====================

M2 Get custom script or take private lessons



#1
July 29, 2016 at 18:19:44
Do we get to pick which file to transfer, and the server to send it to?

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
July 29, 2016 at 21:17:32
::======== FTPAFILE.BAT 30 July 2016 11:16

@echo off > ft.txt

>> ft.txt echo o ftp.mysite.com
>> ft.txt echo username
>> ft.txt echo password
>> ft.txt echo bin
>> ft.txt echo prompt
>> ft.txt echo put filename.txt
>> ft.txt echo bye

ftp -s:ft.txt

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#3
August 1, 2016 at 00:52:48
@Razor2.3 The server is a ftp I need to copy a .txt file
@Mechanix2Go I tried this version but somehow it doesn't work.
I can't find the file on the ftp at the location I choose.
I am new to this so I don't know where the error is... :(

@echo off > ft.txt

>> ft.txt echo o ftp://ftp.totalpartsplus.com/abc/newfolder/
>> ft.txt echo user001
>> ft.txt echo abcd1234
>> ft.txt echo bin
>> ft.txt echo prompt
>> ft.txt echo put C:\Users\user001\Desktop\New folder\Test.txt >> upload.txt
>> ft.txt echo bye

ftp -s:ft.txt

I NEED HELP!

message edited by Alex_SKP


Reply ↓  Report •

Related Solutions

#4
August 1, 2016 at 01:31:35

It's probably not connecting.
Look at the script output; it will let you know.

Try changing:
>> ft.txt echo o ftp://ftp.totalpartsplus.com/abc/newfolder/

to:
>> ft.txt echo o ftp.totalpartsplus.com
If it then connects, you need to do a CD on the site:
CD abc/newfolder

And you probably need the file to send in the current directory.

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#5
August 1, 2016 at 04:45:10
I can't test it because I don't have accress to your site. But this may be close:
::====================================================================
@echo off > ft.txt

copy "C:\Users\user001\Desktop\New folder\Test.txt"

>> ft.txt echo o ftp.totalpartsplus.com
>> ft.txt echo user001
>> ft.txt echo abcd1234
>> ft.txt echo bin
>> ft.txt echo prompt
>> ft.txt echo CD abc/newfolder
>> ft.txt echo put Test.txt
>> ft.txt echo bye

ftp -s:ft.txt

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#6
August 8, 2016 at 02:31:11
I am trying to use the batch you created but it only makes a copy of the txt file on my desktop and is also creating a ft.txt file.
I tried with both ways as you described :
"
Try changing:
>> ft.txt echo o ftp://ftp.totalpartsplus.com/abc/newfolder/

to:
>> ft.txt echo o ftp.totalpartsplus.com
If it then connects, you need to do a CD on the site:
CD abc/newfolder


Am I doing something wrong?


Reply ↓  Report •

#7
August 8, 2016 at 19:24:29
I suggest that you perform the steps manually, recording all your typed responses, then put that material into a test script. The hitch seems to be in the logon sequence. If you can successfully log in to the ftp server "manually", then put that same sequence into a text file, f/e: login.ftp, then try:
ftp -s:login.ftp
I believe that Ftp sites run different server applications, and they vary in how they want the login information presented. You need to determine exactly what your FTP server wants by running a manual login. Then your script should simply re-iterate those manual entries. F/E, my server login ftp-script looks like this:
open pages.suddenlink.net
myusername
mypassword
Until you get the "230 login successful" you will get no-where else.
With that material in a ftp script-file, I have no trouble logging in using the commandline: FTP -S:login.ftp
If/when you achieve login, the rest is fairly straightforward using the content that M2go offered.

message edited by nbrane


Reply ↓  Report •

#8
August 8, 2016 at 20:49:01
✔ Best Answer
Make a new directory and put this bat there.
Run it and take note of whether the COPY worked.
And, yeh, it will create an ft.txt file.


::====================================================================
@echo off > ft.txt
copy "C:\Users\user001\Desktop\New folder\Test.txt"
echo if you don't see:
echo 1 file(s) copied
echo your file isn't where you think and you need to find it
pause

>> ft.txt echo o ftp.totalpartsplus.com
>> ft.txt echo user001
>> ft.txt echo abcd1234
>> ft.txt echo bin
>> ft.txt echo prompt
>> ft.txt echo CD abc/newfolder
>> ft.txt echo put Test.txt
>> ft.txt echo bye

ftp -s:ft.txt

=====================

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •


Ask Question