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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

[resolved] File sync

Hi I want to keep the files at two locations in sync with each other.The two file locations will be passed as the context variables.
e.g.
let one location is C:/source
and the other is C:/target
When my job runs for the first time it should first check the source folder and match them with the contents of the target folder. If there is a difference in the two locations the files need to be copied to the other location.Basically the two folders need to be in sync with each other. If there are new files in the target folder they need to be copied to the source and vice versa.

Any help on the above will be highly appreciated.
Thanks in Advance
Abhineet
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi
Using tFileList to iterate each file in source folder, check the file if it exits in the target using tFileExist, copy it to target folder with tFileCopy if not. Foe example:
tFileList--iterate--tJava--componentOK--tFileExist--runIf--tFileCopy
Best regards
Shong

View solution in original post

18 Replies
Anonymous
Not applicable

Hi
Using tFileList to iterate each file in source folder, check the file if it exits in the target using tFileExist, copy it to target folder with tFileCopy if not. Foe example:
tFileList--iterate--tJava--componentOK--tFileExist--runIf--tFileCopy
Best regards
Shong
_AnonymousUser
Specialist III
Specialist III
Author

Thanks Shong!
Seems good..Do I need to follow the same steps in another flow while I check the target folder?
Because there may be a scenario that there is a new file in the target folder that also needs to be copied in the source folder.
Regards,
Abhineet
Anonymous
Not applicable

Hi
Yes, use the same way to check the target folder in next subjob.
Best regards
Shong
_AnonymousUser
Specialist III
Specialist III
Author

Hi
Using tFileList to iterate each file in source folder, check the file if it exits in the target using tFileExist, copy it to target folder with tFileCopy if not. Foe example:
tFileList--iterate--tJava--componentOK--tFileExist--runIf--tFileCopy
Best regards
Shong

Hi I trying the same solution but I am bit unfamiliar with Java.Can u help me out with the sample Java code to be used in tJava component.
Regards,
Abhineet
Anonymous
Not applicable

Hi,
Don't think you need to use a tJava (shong correct me if i'm wrong 0683p000009MACn.png). Just link your tfileList to the tFileExist.
tFileList--iterate--tfileExist---runif---tfilecopy
_AnonymousUser
Specialist III
Specialist III
Author

Hi,
Don't think you need to use a tJava (shong correct me if i'm wrong 0683p000009MACn.png). Just link your tfileList to the tFileExist.
tFileList--iterate--tfileExist---runif---tfilecopy

I'm not sure if tfileExist is a standalone component because when I am using the combination
tFileList--iterate--tfileExist---runif---tfilecopy
it gives me a syntax error in the tfileExist component.
Regards,
Abhineet
Anonymous
Not applicable

show me your job and what you have put in your tfileexist component
_AnonymousUser
Specialist III
Specialist III
Author

My Bad!
seems to be working now...guess there was some mistake in the "if" condition.

Regards,
Abhineet
Anonymous
Not applicable

Sometimes it's good to switch in the source view, it's easier to detect the errors