Automation Workshop can automate business tasks without writing a line of code. Let's see how we can ensure file integrity when moving them to archive.
Files from multiple sources are copied to
C:\Input\Files folder. At regular intervals, 4 times a day, Automation Workshop moves folder contents to a unique date-based backup folder. Before moving files to backup their names, sizes, checksums and last modified dates are recorded in a
.csv text file to provide means for verifying file integrity later. We will collect data on files before moving them to backup folder.
Set up the Task Scheduler trigger that will run the Task 4 times a day (once in every 6 hours). The Task will list all files in the
C:\Input\Files folder. A subfolder with date and time in its name will be created in
If there are no files, a corresponding record will be written in the no
files.txt file in the
C:\Backup\Date folder. If there are one or more files, for each of them a series of Action will be performed:
First, let's setup a Task Scheduler trigger that will regularly launch the Task with 6 hour intervals. Specify a start date and time and hourly schedule with 6 hours recurrence period.
Let's setup Actions for the Task. This is how the Action tab of a fully configured Task looks like:
The information among Actions is passed by Variable Wizard (see underlined elements in the Action tab and green, bold text in parameter fields of Actions).
Notice the indent of Write to File and For each Actions relative to the If and Else Actions. It means that the first Write to File Action will be performed only if number of files in folder is 0, while the second Write to File action will be performed, if the number of files in folder is not 0.
Likewise, the indentation in front of a group of Actions (relative to the For Each Action) indicates that they are subordinate to the For Each action. For Each runs its subordinate Actions for every file it processes (as it processes files retrieved by List Files Action and stored in the List of files variable).
Let's use the List Files Action to retrieve the list of all files currently in the
Let's use the Create folder Action to create a subfolder in the
C:\Backup folder with current date and time in its name. We will store both reports and files here.
Insert variable after
C:\Backup\ text and choose Preset: Sortable file (dashed).
Now we will verify whether there are currently any files in
C:\Input\Files folder. If there are none, we will note it in
no files.txt file. Else (if there are some) we will process them one by one and store information in the
Use Variable Wizard to retrieve the Number of files variable from the List files Action.
Add the Write to file Action that will write the
No files… text in the
no files.txt file when there are 0 files listed.
Add the Else Action to denote the alternative conditional branch. As specified in the If part, this branch will only be performed when the List files Action returns more than 0 files. See that it has the same indentation level as the If action (i.e., no indent or the leftmost side of the list). Add a subordinate Write to file Action.
To ensure full compatibility with Microsoft Excel, uncheck Save file using Unicode encoding checkbox in options tab.
Text to write field is organized in comma-separated column that correspond with the order of the following Actions which will provide data for each of them. Note the 3 variables in the configuration of the Write to file Action:
1) Last folder value is taken from the Create folder Action to specify that the report file will be created in the
2) Date in
Report-Date.csv is taken from the Date variable set to Year / Month / Day format with leading zero added (so that chronological order match the alphabetical one).
3) Number of files variable is taken from the List files Action.
When all 3 variables are combined in Write to file Action, it creates a unique csv file with current date in its name in the previously created folder and writes a comma-separated header row that defines its structure.
Now let's fill this csv file with data about each listed file. We will process each file one by one, read its data and store it in the created csv file.
When collecting information about listed files, we will run the same set of Actions for each file. The For each Action will perform the cycle by launching subordinate Actions one by one. Add For each Action and use Variable Wizard to load List of files from List files Action.
For each Action will split a file list in individual files and run a set of subordinate Actions for every file.
Now, let's collect relevant data to fill the csv file. We will use 3 Actions:
Use Variable Wizard to refer to Current item in the Compute file checksum Action to get hash cryptographic checksum for a file processed in current step of the cycle.
Use Variable Wizard to refer to Current item in the Get date and time Action to get information when the file processed in current step of the cycle was last modified.
Once all the three Action have collected the necessary data on current file, let's use Write to file Action to write it in csv file.
Using Variable Wizard we will complete a few steps to collect all necessary data together.
As a result, the information will be collected for each file in the For each loop (that takes file list from the List files Action) and stored in a unique csv file.
Finally, let's move the processed file itself to the Backup folder (where we stored the csv file).
Let's create a Move file Action and use Variable Wizard for both Source and Destination parameters — for source use Current item from the For each Action; for destination refer to the Last folder in Create folder Action.
The resulting Task consists of 12 distinct Actions that are performed once every 6 hours. The Actions analyze whether there are files in
C:\Input\Files folder and reports every run in a unique date-based backup folder.
When files are found, various data is collected and stored in csv file to ensure backup integrity before moving files to the backup folder.
If you have any questions, please do not hesitate to contact our support team.
I'm very happy with Automation Workshop. It increased my productivity by tenfold!—Charles J.