2013-11-27 76 views
0

我正在尋找一種方法來創建Talend DI的文件夾結構(使用Talend Studio 5.2.0)。用Talend創建整個目錄結構DI

我有一個臨時文件夾中包含這樣的事情:

/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 

的想法是爲了取/tmp/myjob作爲根源文件夾和拓藍分量來重新創建整個目錄結構在destination配置tFTPPut(遠程)夾。

我試圖把下面的線路中的filemask屬性:

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

當我執行任務,它使以下錯誤:

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

任何人都知道,如果它可以創建這樣的任務?

回答

2

不幸的是,tFtpPut不能讓你創建遠程文件夾的可能性。唯一的解決方法是通過ssh連接並觸發正確的CMD/Bash命令。

關於您的文件掩碼問題,我的建議是使用Perl5正則表達式語法來表示掩碼模式。它的功能更強大,標準和有據可查。但是如果你的源代碼結構非常複雜,一個更好的節省時間的解決方案可能會在源計算機上壓縮整個東西,然後ftp包,最後在遠程機器上解壓縮(再次通過ssh連接)。

我知道這不是一個通用的解決方案:事實上,在遠程機器上ssh並不總是可行的。但對我而言,這是唯一可能的解決方法。

+0

感謝您的建議,最後我做了之前的ssh命令來創建文件夾結構和另一個之後將上傳的文件移動到正確的目錄。對於perl正則表達式語法,我使用它,但我找不到在perl正則表達式和其他tFtpPut組件之間切換的方式。 –

+0

您應該在「文件」表格上方看到一個標記爲「使用Perl5正則表達式作爲文件掩碼」的複選框。這就是魔術。 –

+0

tFTPPut組件中沒有這樣的框。但我正在使用Talend Studio 5.2.0版本,可能是一項新功能。 –