This question already has answers here:
I can't upload a multiple files to FTP by batch script
(3 answers)
Closed 4 years ago.
I try to copy a lot of files from my ftp server ftp://ftp.prodega.ch, so I created a file called code.txt with this text:
open ftp.prodega.ch
user
password
lcd E:\f2
cd Bilder1
get file1.jpg
bye
Then I execute the following command in the command prompt:
ftp -s:code.txt
The file file1.jpg is copying into local E:\f2 folder; I try to copy all files from the ftp folder Bilder1 using mget * instead of get file1.jpg but it doesn't work.
The first image is copied successfully, but the second image (using mget *) doesn't get copied and showed this result:
How would I be able to copy these files?
Try entering this command into your command prompt:
ftp -i -s:code.txt
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.
This question already has answers here:
How to ftp with a batch file?
(10 answers)
Closed 4 years ago.
I am trying to create a script which copies the contents of one directory to an FTP location but every example I have tried to work with has failed. I need this to target a folder within the FTP site can anyone point me in the right direction.
Thank you
Batch file is below.
#ftp -i -s:"%~f0"&GOTO:EOF
open 0.0.0.0
name#address.com
Pa55word
!:--- FTP commands below here ---
lcd c:\program files\system\location
cd storage
binary
mput "*.*"
disconnect
bye
Once FTP is open you are no longer at a command prompt. You are inside FTP. You need to use your batch file to write the ftp script,FTPInstructions.ftp in the following example. Then open ftp, telling it to run the script.
When you invoke the ftp.exe program to run the ftp script from the batch file you can redirect the ftp.exe console output to a log file and examine that log file for errors. You'll need to redirect both stdout and stderr. Something like this:
echo open 0.0.0.0>FTPInstructions.ftp
echo user UserName>>FTPInstructions.ftp
echo Password>>FTPInstructions.ftp
echo something>>FTPInstructions.ftp
echo something else>>FTPInstructions.ftp
.
.
echo bye>>FTPInstructions.ftp
ftp.exe -n -s:FTPInstructions.ftp>FTPSession.log 2>&1
You can then use FIND or FINDSTR in the batch file to locate any error messages output by ftp.exe in the FTPSession.log file.
This question already has answers here:
psftp.exe get files from the server and delete
(3 answers)
Closed 4 years ago.
I was wondering if someone knows how to do what I'm looking to do.
For my server, I download files from an FTP server daily at 5AM. My batch script is pretty simple, it connects to the FTP server, downloads the files, processes them locally, and then deletes the processed files from the local directory, but I am unable to figure out how to get the batch file to purge only the downloaded files from the server.
Here is the code I'm currently using (edited for privacy)
C:
cd "C:\targetfolder"
rem psftp -b download.cmd -i priv(second).ppk -P 2223 xxx#yyy.ca
psftp -b download(second).cmd -i priv(second).ppk -P 2223 xxx#yyy.ca
rem psftp -b download.cmd -i priv.ppk xxx#yyy.ca
psftp -b download.cmd -i priv.ppk -P 2223 xxx#yyy.ca
rename *.xxx *.xxx
del done*.*
So the script as it is successfully is run every morning and downloads my new files. Are there some line(s) of code I'm missing that will simply delete the downloaded files only?
I also want to mention that I cannot install any new software on my FTP server to manage the files, so it has to be processed in my batch code here.
Thank you in advance for any help you all may be able to provide!
EDIT1: Here is the script in the doanload.cmd
ls
cd target
ls
mget *
Solved, thanks to #MartinPrikryl.
I added "rm *" to the end of my cmd file and it's working nicely, even though it doesn't differentiate from downloaded and non-downloaded files, it does what I need.
Thanks #MartinPrikryl!
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.