如何下载FTP文件夹最新 [英] How to download latest folder from ftp
问题描述
喜做任何身体知道如何从FTP下载最新的文件夹中。我有这样的文件夹Evolvenet_20111112.1
Evolvenet_20111113.1
从这个我必须下载最新的文件夹中。任何一个可以请帮我用一个例子。
hi does any body know how to download latest folder from FTP. I have folders like Evolvenet_20111112.1 Evolvenet_20111113.1 from this i have to download latest folder . Can any one please help me with an example.
在此先感谢,
Bhasker。
Thanks in advance, Bhasker.
FTP上市不工作,因为我的构建文件夹均\\编译\\ Evolvenet 2010 \\。上市将采取默认的文件夹登录到FTP服务器后。有什么办法可以指定到该文件夹跳转和列表。
Ftp listing is not working because my build folders were in \build\Evolvenet 2010\ . Listing will take default folder after logging into the ftp server. Is there any way to specify to goto that folder and list.
谢谢,
Bhasker。
Thanks, Bhasker.
推荐答案
我想你需要做的就是把它分解成步骤:
I think what you'll need to do is break it down into steps:
- 与FTP列表相关的文件
- 从列表中提取文件名
- 排序文件名
- 从排序列表在第一个或最后一个文件名
- 获取该文件,FTP
由于您的文件使用一个名为年月日<版本的方式>
模式,你可以简单地按名称排序文件把它们按日期顺序排列
Since your files are named using a yyyyMMdd.<version>
pattern, you can simply sort the files by name to put them in date order.
第1步:列表中的文件是这样的
Step 1: List the files something like this
<ftp action="list"
server="${server}" userid="${user}"
password="${password}" listing="list.txt">
<fileset>
<include name="Evolvenet_*"/>
</fileset>
</ftp>
步骤2-4,:提取自上市最新的文件
Steps 2-4: Extract newest file from the listing
<loadresource property="newest.file">
<concat>
<fileset file="list.txt"/>
</concat>
<filterchain>
<tokenfilter>
<replaceregex pattern=".*(Evolvenet_.*)" replace="\1"/>
</tokenfilter>
<sortfilter reverse="true"/>
<headfilter lines="1"/>
</filterchain>
</loadresource>
<echo message="newest.file ${newest.file}"/>
第5步:获取文件,FTP
<ftp action="get"
server="${server}" userid="${user}"
password="${password}">
<fileset dir="download">
<include name="${newest.file}"/>
</fileset>
</ftp>
我已经回答了,好像Evolvenet_ *有文件,但我注意到你说他们是目录。我认为所有需要切换到下载目录是FTP获取包括条款:
I have answered as if Evolvenet_* were files, but I notice you say they are directories. I think all that needs to change to download the directory is the include clause in the FTP get:
<include name="${newest.file}/**"/>
要列出某个目录(而不是用户的登录目录)的内容,使用文件集的 DIR
属性来指定远程目录,如:
To list the contents of a certain directory (rather than the user's login directory), using the dir
attribute of the fileset to specify the remote directory, e.g.
<fileset dir="/build/Evolvenet 2010">
<include name="*"/>
</fileset>
这篇关于如何下载FTP文件夹最新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!