Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] current_file in tFTPFileProperties

Hello !
In order to find the most recent file contained in a folder on a FTP server, I'd like to use to tFTPFileProperties on each file of the folder.
I have a tFTPFileList in which my directory is "/home/folder"
I've linked the tFTPFileList to a tFTPFileProperties in which I wanted to get all the file names using "((String)globalMap.get("tFTPFileList_1_CURRENT_FILE"))"
However "((String)globalMap.get("tFTPFileList_1_CURRENT_FILE"))" is returning me "/home/folder/filename1" instead of just "filename1" and I don't know how to get the file name without the file path.
( "((String)globalMap.get("tFTPFileList_1_CURRENT_FILEPATH"))" is giving me "/home/folder//home/folder/filename1" )
Is this a bug ? How can I get the file name alone ? 0683p000009MACn.png
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello
It is not a bug, the return value is a absolute path of file.
How can I get the file name alone ?

tFTPFileList --iterate-->tFTPFileProperties
Output the basename column of tFTPFileProperties, that's the file name alone.
Best regards

shong

View solution in original post

7 Replies
Anonymous
Not applicable
Author

Hello
It is not a bug, the return value is a absolute path of file.
How can I get the file name alone ?

tFTPFileList --iterate-->tFTPFileProperties
Output the basename column of tFTPFileProperties, that's the file name alone.
Best regards

shong
Anonymous
Not applicable
Author

Thank you shong ! However, my problem was concerning the tFTPFileProperties settings as I wanted to put the filename in the "file" field.
Can you tell me how I can do this ? 0683p000009MACn.png
Anonymous
Not applicable
Author

Hello
my problem was concerning the tFTPFileProperties settings as I wanted to put the filename in the "file" field.

You should put the file path in the file filed of tFTPFileProperties, if you link a tFTPFileList to tFTPFileProperties, the file path shoud be set as:
((String)globalMap.get("tFTPFileList_1_CURRENT_FILEPATH"))
why would you like set it as the file name only?
Best regards

shong
Anonymous
Not applicable
Author

I don't understand because here are my results according to my settings when using only a tFTPFileProperties linked to a tLogRow :
remote directory : "."
file : "/home/folder/filename.txt"
result : |||||

remote directory : "/home/folder/filename.txt"
file : "."
result : Exception in component tFTPFileProperties_1
com.enterprisedt.net.ftp.FTPException: Unable to determine if file '/home/folder/filename.txt/.' exists.

remote directory : "/home/folder/"
file : "filename.txt"
result : /home/folder/filename.txt|/home/folder/|filename.txt|4023|1241444237000|Mon May 04 15:37:17 CEST 2009
So it seems to me that I really need to separate the filename from the filepath to get what I want... Is there something I don't understand here ? 0683p000009MACn.png
Anonymous
Not applicable
Author

Hello
I understand you now, you have set the file path in remote directory. Now, you can get the file name like this:
((String)globalMap.get("tFTPFileList_1_CURRENT_FILE")).substring(((String)globalMap.get("tFTPFileList_1_CURRENT_FILE")).lastIndexOf("/")+1)

Best regards
shong
Anonymous
Not applicable
Author

Hello Augustine,
you can get only the filename with this expression in a Tmap :
row.basename.substring(row.basename.lastIndexOf("/")+1)
Anonymous
Not applicable
Author

Thank you shong ! This is what I needed 0683p000009MACn.png