Batch File To Download From Ftp By File Type

February 18, 2010 at 02:55:53
Specs: Windows 7
HI,

I am trying to make a batch file that downloads all files from my ftp server not by there filename but by there file type. The file type I need it to download is .occ and .ord

This is the code I have that can download from ftp by a filename:

::---Start download.cmd---
@echo off
setlocal

::Variables
set f=%temp%\ftpc.txt

::Compose ftp commands file
echo open HOST>>%f%
echo user USER PWD>>%f%
echo binary>>%f%
echo cd /htdocs/acatalog>>%f%
echo get FILENAME>>%f%
echo bye>>%f%

::Execute ftp command
::Use "-d" key for verbose output
ftp -n -d -s:%f%

::Cleanup
del /f /q %f%
endlocal
::---End download.cmd---

also while I am posting on here, Does anyone know of a way to change file permissions on my server through a batch file.

Simon


See More: Batch File To Download From Ftp By File Type

Report •


#1
February 18, 2010 at 04:01:14
@echo off > # & setLocal enableDELAYedexpansion

>> # echo o mysite.com
>> # echo user
>> # echo pass
>> # echo cd /incoming
>> # echo bin
>> # echo prompt
>> # echo mget *.occ
>> # echo mget *.ord
>> # echo bye

ftp -s:#


=====================================
Helping others achieve escape felicity

M2


Report •

#2
February 18, 2010 at 04:12:16
If you need files in sub-directories (as you mention "all files from my ftp server", not "all files in a given directory/folder") you need a tool similar to (or exactly) like this http://users.ugent.be/~bpuype/wget/ (which is a windows FTP command line tool that can handle subdirectories easily)

Don't know about changing permissions, FTP is not aimed at that goal, BUT, by means of using GET and PUT, maybe you can (re)set permissions in a particular way. The CHMOD commands can only be run in TELNET, not FTP ... or somebody may have thought about that, and written an FTP tool with that feature ...


Report •

#3
February 18, 2010 at 04:19:58
ok I tryed that but now in the command prompt it says this,

ftp> mget *.ord
---> TYPE A
---> PORT 192,168,0,151,246,78
---> NLST *.ord
---> TYPE I
200 TYPE is now 8-bit binary
mget ttssf.ord? mget *.occ
ftp> bye
---> QUIT

and nothing gets coppied over?


Report •

Related Solutions

#4
February 18, 2010 at 04:24:30
Post contents of # file.


=====================================
Helping others achieve escape felicity

M2


Report •

#5
February 18, 2010 at 04:28:27
the file is encoded, however I tryed to download just a .png from the server and this also did the same thing:

ftp> open ftp.*******.co.uk
Connected to ftp..*******.co.uk.
220-Matrix FTP server ready.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 Please note: files for your website must be stored under the htdocs director
y.
ftp> user ******* *******
---> USER *******
331 User ******* OK. Password required
---> PASS *******
230 OK. Current directory is /
ftp> binary
---> TYPE I
200 TYPE is now 8-bit binary
ftp> cd /htdocs/acatalog
---> CWD /htdocs/acatalog
250 OK. Current directory is /htdocs/acatalog
ftp> mget *.png
---> TYPE A
---> PORT 192,168,0,151,248,111
---> NLST *.png
---> TYPE I
200 TYPE is now 8-bit binary
mget bball.png?
ftp> bye
---> QUIT
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.


Report •

#6
February 18, 2010 at 04:32:11
here is my batch file:

::---Start download.cmd---
@echo off
setlocal

::Variables
set f=%temp%\ftpc.txt

::Compose ftp commands file
echo open ftp.*******.co.uk>>%f%
echo user ******* *******>>%f%
echo binary>>%f%
echo cd /htdocs/acatalog>>%f%
echo mget *.png>>%f%
echo bye>>%f%

::Execute ftp command
::Use "-d" key for verbose output
ftp -n -d -s:%f%

::Cleanup
del /f /q %f%
endlocal
::---End download.cmd---


Report •

#7
February 18, 2010 at 04:41:20
ok got it working needed to use the prompt command before downloading

Report •

#8
February 18, 2010 at 04:49:17
"the file is encoded"

I have no idea what that means. But I guess you're not trying to use the script I posted.


=====================================
Helping others achieve escape felicity

M2


Report •

#9
February 18, 2010 at 05:35:23
Maybe source dir does not contain these files ... put in an additional LS command ... or the files end up on your machine, where you don't except. But to me it looks source = empty (for those files). Or default "prompt" (on/off) is different ?

Just take your inputfile (or any inputfile) and enter the commands manually, like listed in the file. See what happens. Can't be that hard.


Report •

#10
February 18, 2010 at 07:48:45


Report •

#11
February 18, 2010 at 08:17:26
I didn't see what you wrote nbrane, but I do see the 24 space's to get around the "short message" error ;)

<blockquote><table width="100%"><tbody><tr><td><p>                        <br></p></td></tr></tbody></table></blockquote>



Report •

#12
February 18, 2010 at 15:00:33
Sorry about that... maybe bad etiquette? My original response/solution was already solved by the OP, so i just took mine out since we can't delete them.

Report •


Ask Question