I need to get files that were created today and move these files to another folder. Can I use the File Management Utility to get the files and put a filter to only copy those files with a 'Created' date of today? How will I do this?
Use the Get Files action to retrieve the list of files into a collection. Loop through the collection, and in the loop, use the Move File action to move the file to the other folder if its Create Date or Modified Date = Today().
The way Get Files works is you provide the folder path and (optionally) a string pattern to look for in the filename (with wildcard * if desired). The entire list of files found in that folder (optionally matching the string pattern) will be output to a collection whose name you provide in the Outputs configuration. Then, to see if it is created today, you need to loop through the collection and read the Create Date field. You can then test to see if Create Date = Today() or not and proceed accordingly.
Copy File requires the source path and filename and the destination path and filename.
So if your intent is to copy today's files to a folder, for example, you do the following:
1. Get all files from the source folder into a collection.
2. Loop through the collection. Examine Create Date and if the date is today, then copy the file to the destination folder. If the date <> today, go to the end of the loop and look at the next file/row in the collection. Repeat for all rows in the collection.
So are you saying that I will be able to get only the files using Get Files with a string pattern in the filename(can use wildcard). Will string pattern only look at filename? Can it not look at "Created" date in the string pattern?
If I bring in all the files in the folder using Get Files then read the Collection Fields. When I get to the "Created" field, I compare the date to today's date. Refer attached.
My problem now is that it only reads the first row in my collection. What do I do in order for it to loop through the rows? View attachment 1593600180734.png
Firstly, the string pattern only applies to the filenames. It won't work for the Created Date.
Secondly, please reevaluate why you are using nested loops. i can't see the configuration details, but it looks like the Get Files action is populating the All Files collection. You are then correctly looping through the All Files collection. I think you can delete the Loop Collection start and end stages and it will work. (I thnk you're doing this because you feel you need to read the fields in the All Files row.) In the loop, you don't need the Read Collection Fields stage. In the decision, you can refer to the Created Date from the collection and compare it to today's date as follows: "[All Files.Created Date]=Today()". You may need to add formatting. The Yes condition will point to Copy File and then to the Loop All Files loop end stage. The No path will go directly to the Loop All Files loop end stage.
Pete, Thank you for your patience.
I was following a solution found in another forum where the Collection fields had to be read. Not sure why the dot notation was not used there.
I managed to get it right with your guidance.
Thank you very much for your help.