How can I write a MS dos ftp batch file to:
download files from the server to my local pc
remove these files from the server after download
Edit:
So far I have...
Batch file:
ftp.exe -s:ftp.txt
FTP.txt:
open domain.com
usernamehere
passwordhere
cd /httpdocs/store/files
need get, list and delete commands here??
quit
The ftp.exe program can take a sort of script file as input (that example uploads a file, but I guess to get the idea), so you should probably be able to create a script for the commands that you need to carry out, and then have a batch file launch ftp.exe with the appropriate input.
From one of my cuestions in other post.
user-name
user-password
lcd c:\localfolder-where-download
cd remote-folder
mget .
mdelete \\remote-folder\ .
quit
1 & 2 line , your credentials
3 - line local folder where the ftp can download the content
4- line - remote folder if needed
5- line - get al content to your local folder
6- line - delete all content from your remote folder
7- line quit!
you can download ncftpput/ncftpget. With ncftpget, there's option to remove remote files after downloading.
Related
I'm trying to download a file from an FTP using a script:
Script.bat
ftp -s:DownloadFiles.ftp
DownloadFiles.ftp
open ftp_server
user
pass
ascii
prompt
lcd D:\LocalPath
mget "File.*.TXT_T;1"
When I run the Script.bat I get the following error:
550-Failed to open CV0:[user]File^^^.20171104_024043.TXT_T; for input
. 550 file not found
According to this link, the problem seems to be that the file name contains multiple dots and the mget command will not found the file. Updating the server might solve the problem but I can't do that.
Has anyone dealt with this before?
This question already has answers here:
Batch file to upload all files in directory to FTP
(2 answers)
Closed 5 years ago.
I need to upload a set of .txt files to an FTP server using a .bat file. So far, I've managed to connect to the FTP server, including the correct directory that I need to put the file into and then disconnect. However, it isn't uploading the files.
In my .bat file, I've got this line to start the process
ftp -s:ftp.txt
Then, in ftp.txt, I've got
open my.ip.address
myUserName
myPassword
binary
cd myDir
cd myDir
put C:\MyFolder\*
quit
It goes to the correct directory when I run the batch file, the output being
OK. Current directory is /myDir/MyFolder
ftp> put C:\MyFolder*
Error opening local file C:\MyFolder..
ftp> quit
Goodbye. You uploaded and downloaded 0 kbytes.
Why is it erroring when trying to upload all files from C:\MyFolder\? Is there another way to upload all of the files from a folder?
put is used for a single file. To upload multiple files, use mput instead.
mput C:\MyFolder\*
You may also want to put a prompt on the line before the mput line so that you aren't prompted to press Y for each file in the folder.
I try to copy a lot o file from my ftp = ftp://ftp.prodega.ch so:
I created a code.txt file with this text:
open ftp://ftp.prodega.ch
user
password
lcd /D "E:\f2\" //this is my local directory
cd Bilder1/ //this is ftp folder
mget *
pause
the I execute in cmd this row : ftp -s:code.txt but I meet with this error:
unknown host: ftp://ftp.prodega.ch
help me please
When connecting to a server via the built-in FTP client you have to skip ftp://!
So open ftp.prodega.ch will fix your issue.
However, you might still face another problem. The standard FTP client doesn't support passive mode which is required by most of the servers. If you are not able to modify the server, you won't be able to download the files. You should consider using a PowerShell script instead or use a different FTP client with command line support.
I am trying to upload entire a folder to ftp but it just uploads one file, what could be the problem?
Open Run window → cmd → ftp -s:C:\ftpfile.bat
This is my batch code code:
open FTP address
USERNAME
PASSWORD
bin
mput C:\user\*
bye
Thanks from now.
Have you tried to use prompt before mput in order to deactivate interactive mode?
open FTP address
USERNAME
PASSWORD
prompt
bin
mput C:\user\*
bye
I am using this script to upload files using FTP. However, it is uploading to the root folder in the server.
Can any one tell me to upload the file to a particular path on remote server, say '/CurrentQA'?
Before this line:
ECHO binary >> %Commands%
Try adding this line:
ECHO cd /some/directory >> %Commands%
This should enter the desired directory in the remote server (I haven't tested it though).