Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Moving the files based on file pattern

Hi Team,

 

I want create job below logoc.

 

FIRST RUN.

1) One common directory(i.e C:/Landing)

 

files in C:/Landing:

 

AAA_2017_0610_024629
AAA_2017_0611_024623
AAA_2017_0612_024622
BBB_2017_0612_024300
CCC_2017_0612_024300

2) Move the files to specific directory based on starting pattern. like AAA, BBB and CCC.

Move C:/Landing to C:/AAA
Move C:/Landing to C:/BBB
Move C:/Landing to C:/CCC

Note:
1) Move one file at time to specific directory(Like AAA) for each run.(i will secedule job every 5 mins).
2) Once file is moved to specific direcory delete the files from C:/Landing directory.
3) Move is done based old dates not latest date. ex: move files 10th , 11th and 12th date order.(NOTE: move one file at time for each run).

Second RUN.

same process, only it will move next file if mutiple file exist based on dates.


fisrt run:
move AAA_2017_0610_024629 to c:/AAA
move BBB_2017_0612_024300 to c:/BBB
move CCC_2017_0612_024300 to c:/CCC


second run:
AAA_2017_0611_024623 to C:/AAA

etc.

 

Kindly help on above scanario.

 

Thanks

Shree

Labels (2)
12 Replies
Anonymous
Not applicable
Author


@bshree88 wrote:

Hi Richard,

 

Please find the below are my answer.

 

Your initial question seemed to suggest that the pattern dictated the folder the file would be in? Has this changed? If you are talking about the path of the folder, you can edit the job using a context variable which can be changed quite easily. But the pattern at the front of the file must match the folder, or how do you know where the file goes?

 

Ans: Destination folder is anything. only i want to move the files based on patter to any destination folder(Not specific).

 

OK, this can be achieved using a Context variable as the base destination folder rather than hard coding it. You can set the Context variable at runtime.

 

The job will move every file in the input folder. Why would you want to limit it to one file at a time?

 

Ans: Reason is i want to process old date file first to new date files one by one(Each run). need to run every 10 min(frequency is depends).

 

I see. If you load your tFileList values using an iterate to a tFixedFlowInput, you can then store them in a tHashOutput component (Google this if you are not sure). You can then use a bit of Java to get the date from the file and then order by the date. Then it is just a case of using only the first record.

 

This can be done, and would require just taking the first file returned by the tFileList (which can be set to find files in date order).

 

Ans: But i want to set based file date and date is coming with file name. i want to substring the date order by date, pick old date and move to destination folder.

 

An easy way of doing this is to store the files found n memory and only use the first file. There are other ways.

 

Ans: How to achive 3rd one. storing in meory and move  single old date file to destination folder.

 

Thaks for your inputs.

 

PFA my job which created. i am facing how to move single file to destination if mutiple file exist with same pattern based on file dates.

 

I am not entirely sure what you mean here. Are you saying that files have the same date and the same folder path pattern? If so, you need to find another way of sorting (an additional way to just date) and do the same as described above. 

 

Regards

Shree

 

 


 

Anonymous
Not applicable
Author

Hi Richard,

 

Please find the below are my answer.

 

Your initial question seemed to suggest that the pattern dictated the folder the file would be in? Has this changed? If you are talking about the path of the folder, you can edit the job using a context variable which can be changed quite easily. But the pattern at the front of the file must match the folder, or how do you know where the file goes?

 

Ans: Destination folder is anything. only i want to move the files based on patter to any destination folder(Not specific).

 

OK, this can be achieved using a Context variable as the base destination folder rather than hard coding it. You can set the Context variable at runtime.

 

Fine..

 

The job will move every file in the input folder. Why would you want to limit it to one file at a time?

 

Ans: Reason is i want to process old date file first to new date files one by one(Each run). need to run every 10 min(frequency is depends).

 

I see. If you load your tFileList values using an iterate to a tFixedFlowInput, you can then store them in a tHashOutput component (Google this if you are not sure). You can then use a bit of Java to get the date from the file and then order by the date. Then it is just a case of using only the first record.

 

Fine..

 

This can be done, and would require just taking the first file returned by the tFileList (which can be set to find files in date order).

 

Ans: But i want to set based file date and date is coming with file name. i want to substring the date order by date, pick old date and move to destination folder.

 

An easy way of doing this is to store the files found n memory and only use the first file. There are other ways.

 

Ans: How to achive 3rd one. storing in meory and move  single old date file to destination folder.

 

Thaks for your inputs.

 

PFA my job which created. i am facing how to move single file to destination if mutiple file exist with same pattern based on file dates.

 

I am not entirely sure what you mean here. Are you saying that files have the same date and the same folder path pattern? If so, you need to find another way of sorting (an additional way to just date) and do the same as described above. 

 

Here, Below  is example same if 

 

if files start with AAA move to C:/TEST/ and that only one file, after move replace from source direcctory. ie. AAA_2017_0612_024622(old date)

 

AAA_2017_0610_024629
AAA_2017_0611_024623
AAA_2017_0612_024622

 

 

I work on as mentison above points.

 

Regards

Shree

 

 

Tasfiahm
Creator
Creator

Hi Richard,

 

Can you please re-share the sample job link. It will be a great help.

 

Thanks,

 

TA