File processing by file date-time

Articles, advices, FAQ, etc.
Post Reply
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File processing by file date-time

Post by Oleg »

File processing with selection by file date and time.

It is often necessary to process a group of files with selection of files by date/time of their creation. Processing can imply any operation. For example:
delete files older than 3 days
archive files older than 1 day and delete originals
move today’s files into another folder
etc
RoboTask allows to solve this problem in several ways.

1. For simple operations like deleting and copying files or moving them to another folder it is possible to compose a simple task with 2 steps:

   Search For Files
   Copy/Move File

Or:

   Search For Files
   Delete File

The action Search For Files allows to create a list of files by the file mask and to save it in a text file. The action also allows to select a file by date. Use settings Date Filter.

Save the list, for example, in a temporary folder in the file LIST.TXT.

   {TempDir}\List.txt

The actions Copy/Move File and Delete File allow to process a list of files. Therefore, specify the following expression as a parameter Files:

   {TextFile({TempDir}\List.txt)}

The variable TextFile returns the contents of the file specified in brackets. During execution of the step, RoboTask expands the variable and substitutes the list created at the previous step into the parameter.

2. The use of File Loop.
The use of the loop provides more flexibility and allows to perform a whole set of operations with every file. File Loop has a similar Date Filter.

File Loop works as follows:
Finds all the files in a folder, which satisfy the criteria of the search;
Saves the next file name (from beginning of the list) in a specified variable (the variable of a cycle) for each repetition;
Repeats the cycle steps located between Loop and End Loop for each file.
Thereby, the loop sequentially processes the whole list of files. Certainly, the steps within a cycle have to use the variable (variables) which stores the next name of the file.
Notice that File Loop can save not only the file name into variables but also the date/time of the file and the size of the file. It is also possible to use these variables in the cycle. For example, in order to apply an additional filter using the actions If...Then.
The task "[DEMO] ClearTemporaryFolder" is based on the same principle. This task is included in the installation package. It is also possible to download the task following this link.
Last edited by Oleg on Tue Oct 02, 2012 2:32 pm, edited 1 time in total.
Post Reply