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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tFileCopy and tFileDelete

Hello,
I try to copy a whole directory (or more) and delete it after.
To do this, i use a tFileCopy component and a tFileDelete component. The problem is when i want to do this on large file (>150Mo) it doesn?t delete every file in the directory.
I think that the problem comes from the tFileCopy. It doesn?t close the file.
Have you any suggestion ?
Regards
Labels (2)
21 Replies
Anonymous
Not applicable
Author

janhess,
I tried checking "includes subdirectories", but the problem with this solution is that, in my tFileCopy component i can't copy directories and files. Maybe, i can try to separate the copy of directories and files with two different tFileList and tFileCopy but actually, i don't know how to do this exactly (because, if i want to copy the directories first, files will be copied too, and if i copy files first, i'm not able to retrieve their former directory).
Anonymous
Not applicable
Author

preatorien,
Put the following in your destination of your tFileCopy:
"DEST FOLDER LOCATION: What you put in your tFileCopy" + StringHandling.RIGHT(((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")),StringHandling.LEN(((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")))-StringHandling.LEN("E:\TestAsupprimerEnsuite\In"))+ "/" + ((String)globalMap.get("tFileList_1_CURRENT_FILE"))

This will do the following: Destination Folder + Subdirectory name + FileName.
Doing this will give you the same directory structure.

Regards
Anonymous
Not applicable
Author

Thank you so much mpa, it works. It?s not a beautiful solution but it works.
I explain my job for those who are interested in. You can see a screenshot of the job in attachment.
tFileList_1 settings :
- Directory : ?E:/TestASupprimerEnsuite/In?
- FileListType : Directories
- FileMask : "AAA*"
Don't check the "includes subdirectories" setting.
tFileList_4 settings :
- Directory : ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
- FileListType : Files
No Filemask, Check "Includes subdirectories"
tFileCopy_1 settings :
- File Name : ((String)globalMap.get("tFileList_4_CURRENT_FILEPATH"))
- Destination directory : "E:/TestASupprimerEnsuite/Out/"+StringHandling.RIGHT(((String)globalMap.get("tFileList_4_CURRENT_FILEDIRECTORY")),(StringHandling.LEN(((String)globalMap.get("tFileList_4_CURRENT_FILEDIRECTORY")))-28))
28 is the length of the directory of tFileList_1, to do this in a beautiful way, you can declare it in context variable.
- Check "Remove source file", "Replace existing file" and "create the directory if it doesn't exist"
- don't check "Copy a directory"
The second part of the job with tFileList_2 and tFileDelete_1 is used to delete the directory (all files are already removed in the tFileCopy component).
tFileLis_2 settings : same as tFileList_1
tFileDelete_1 settings :
- Directory : ((String)globalMap.get("tFileList_2_CURRENT_FILEPATH"))
- Check "Delete Folder"
Thank you mpa.
Anonymous
Not applicable
Author

preatorien,
I don't understand why there are 2 filelists for the copy part, but if it works it's ok I guess :-).
Can I ask you a question?
How did you upload that image, I have been some time on the forum now but never understood it! I always use Regards
janhess
Creator II
Creator II

Would it be better to have the output base directory as a context variable - basedirectory and use len(context.basedirectory).
eg Destination directory : context.basedirectory+StringHandling.RIGHT(((String)globalMap.get("tFileList_4_CURRENT_FILEDIRECTORY")),(StringHandling.LEN(((String)globalMap.get("tFileList_4_CURRENT_FILEDIRECTORY")))-len(context.basedirectory)))
Anonymous
Not applicable
Author

mpa,
I need two tFileList because all my files does not match the filemask. If i only use one of them, i lost some files. Anyway, it works. Thank you again.
To upload images, i use the "Image upload" option that is available under your message when you post a reply.
Regards
janhess
Creator II
Creator II

Click Post reply rather than use Quick post.
Anonymous
Not applicable
Author

preatorien,
I had no idea hehe! After all this time, thanks a lot mate! Will be a lot easier for me to help people on the forums 0683p000009MACn.png
Have a nice day,
Regards
Anonymous
Not applicable
Author

Would it be better to have the output base directory as a context variable - basedirectory and use len(context.basedirectory).

You're right janhess, that's what i do in my real job.
Have a nice day and thanks again
janhess
Creator II
Creator II

Would this work?
context.basedirectory+((String)globalMap.get("tFileList_4_CURRENT_FILEDIRECTORY")).substring(len(context.basedirectory))