使用Talend DI创建整个目录结构

时间:2013-11-27 14:33:04

标签: sftp file-transfer directory-structure talend

我正在寻找一种使用Talend DI(使用Talend Studio 5.2.0)创建文件夹结构的方法。

我有一个包含以下内容的临时文件夹:

/tmp/myjob/type1/file01.txt
/tmp/myjob/type1/file02.txt
/tmp/myjob/type1/file03.txt
/tmp/myjob/type1/fileN.txt
/tmp/myjob/type2/file01.csv
/tmp/myjob/type2/file02.csv
/tmp/myjob/type2/file03.csv
/tmp/myjob/type2/fileN.csv
/tmp/myjob/type3/file01.jpg
/tmp/myjob/type3/file02.jpg
/tmp/myjob/type3/file03.jpg
/tmp/myjob/type3/fileN.jpg

我想将整个目录结构传输到远程FTP(ftps)文件夹。

结果将是:

/destination/type1/file01.txt
/destination/type1/file02.txt
/destination/type1/file03.txt
/destination/type1/fileN.txt
/destination/type2/file01.csv
/destination/type2/file02.csv
/destination/type2/file03.csv
/destination/type2/fileN.csv
/destination/type3/file01.jpg
/destination/type3/file02.jpg
/destination/type3/file03.jpg
/destination/type3/fileN.jpg

我们的想法是配置tFTPPut以便将/tmp/myjob作为根源文件夹和talend组件重新创建destination(远程)文件夹中的整个目录结构。

我尝试将以下行放在filemask属性中:

FileMask                newName
"./type1/*.txt"             ""
"./type1/*.csv"             ""
"./type1/*.jpg"             ""

执行作业时,会出现以下错误:

[statistics] connected
Exception in component tFTPPut_1
2: No such file

有人知道是否可以创建这样的任务?

1 个答案:

答案 0 :(得分:2)

不幸的是,tFtpPut无法让您创建远程文件夹。唯一的解决方法是通过ssh和trig连接正确的CMD / Bash命令。

关于你的文件掩码问题,我的建议是使用Perl5正则表达式语法来表达掩码模式。它的功能更强大,更标准,记录更完善。但是如果你的源代码结构相当复杂,那么更好的节省时间的解决方案可能是在源机器上压缩整个东西,然后ftp包,最后在远程机器上解压缩它(再次通过ssh连接)。

我知道这不是一般解决方案:事实上,并不总是可以在远程机器上进行ssh。但据我所知,这是唯一可行的解​​决方案。