This tutorial will show how to monitor a folder for incoming files and move them automatically to folder with current date in its name.
Suppose that at the end of every working day all employees are uploading their daily reports to network share. Automation Workshop supports UNC paths and mapped drives, but for the simplicity of the example we will use the path
C:\Report\ on local computer.
Upon arrival to the share, these documents are to be moved to
D:\Backup\ folder where later have to be retrievable by the date of their backup. Let us list the necessary steps:
- The creation of the Task itself.
- Adding a Trigger which will watch folder
C:\Reports\for new files.
- Adding an Action which will copy newly arrived file to the backup folder containing current date in its name.
Create a Task
How to create a Task in Automation Workshop? Creating a Task is easy. Just open the Automation Workshop Manager and choose New Task from File menu. This will bring forward the Task Wizard—a step by step configuration tool for setting up the Task parameters (including adding and configuring both Triggers and Actions).
Monitor a folder
How to watch folder for new files? In Task Wizard, go to the Trigger tab and click the Add button (this will open Add Trigger window). Select File & Folder Watcher and click OK. We are automatically brought to File & Folder Watcher Folder properties where we can configure the conditions upon which the Trigger will execute the Task.
First, we need to specify which folder will be monitored. Click on Folder to watch input line and then on the Browse button on the right side of it. Select the
Reports folder on drive
C: and click OK. Now Folder to watch input line contains
C:\Reports. All other settings suit our Task by default.
The newly added File & Folder Watcher will monitor for all new files appearing in
C:\Reports folder without filtering out any files. Just click OK at this point to save Trigger settings and return to the Task Wizard.
How to automatically move files to backup folder? Now we have to add an Action that will move files when triggered. Go to the Actions tab of Task Wizard (next step after Triggers section) and click Add button (this will open Add Action window). Choose Move File Action from File & Folder category and click OK.
Now we are in the File tab of Move File Action properties. Here we have to specify the most important settings, namely, what will be moved (source) and to where exactly (destination).
Let us start with source. We will not specify Move File Action to move just some files located in some folder. Instead, we will move exactly those files that are found by File & Folder Watcher (added in the previous step).
Click on the Variable Wizard button (to the right from Source input line). The list of Variable categories will be opened. We need to take parameters from a Trigger, so we click on the Triggers category and choose File & Folder Watcher: C:\Reports (watch for new files). The default option on the right side, namely, Full path and filename fits perfectly to specify both path and file name for automatic moving operations. Click OK and see Filename in Source input line.
Now let us specify the destination. We need not only to move all files to folder
D:\Backup\, but also to create a subfolder for each day. First let us click on Destination input line and then on Browse button. Select
Backup folder on drive
D: and click OK, which will result in
D:\Backup\ appearing in Destination input line.
Now, how can we tell Automation Workshop to automatically put files into folder that has current date in its name? For such varying parameter we will need to use Variable Wizard again. While cursor is still in Destination input line (after
D:\Backup\) click on the Variable Wizard button.
Since we need to add current date, let us choose the Date variable from Date & Time category. The default format is Month / Day / Year separated by slashes. However, for current purposes this format is not appropriate, since we can not have slashes in file names. Dots in file name specify extensions and can be used in principle. However, it is a much better idea to choose dash as a file system neutral character.
Also, it will be more convenient to see all folders in sequential order when browsing
D:\Backup folder, that is why it is better to choose Year ‐ Month ‐ Day format. Also, check the Add leading zero option to avoid problems with sorting order between dates or months that contain single digit and those with two digits (e.g. 1, 10, 11, 12, 2 vs. 01, 02, 10, 11, 12).
When configured, click OK and you will see
D:\Backup\Date in Destination input line. Finally, in order to specify that Date refers to folder (and not to file name), manually add backslash character at the end of Destination input line. The final content of the input line, thus, has to be:
Unless you would like to filter out some files based on their names, extension, attributes or time, click OK. The Move File Action is configured and the Task is ready to start the daily backups. Just check the reporting options, give Task a name (Task tab) and click Finish to save settings and activate the Task.
From now on, whenever a new file appears in
C:\Report\ folder, File & Folder Watcher will automatically move it to folder containing the current date in its name located in
D:\Backup\ (if non-existent, the folder will be created during automatic file moving operation). Let us consider the following scenario:
- On August 18th, 2020 the file
daily report.docxis put into
C:\Reports\folder. The file is removed from
C:\Reports\and put into newly automatically created folder with the date in its name which itself is located in the
D:\Backup\folder. Now there is
daily report.docxfile in
- On the same day (August 18th, 2020) a file named
weekly report.docxis put into
C:\Reports\folder. The file is removed from
C:\Reports\and put into previously created folder with the date in its name located in the
D:\Backup\folder. Now there are both
weekly report.docxfiles in
- On the same day (August 18th, 2020) a file with the same name as the one already in today's backup (
weekly report.docx) is put into
C:\Reportsfolder. Since Move File Action does not overwrite destination files by default, the
weekly report.docxwill remain in
weekly report.docxfile already in today's backup folder
D:\Backup\2020-08-18\will not be overwritten. A corresponding error message will be logged. Note: If Overwrite destination files option is enabled in Options tab of Move File properties, the
weekly report.docxfile already in
D:\Backup\2020-08-18\folder will be overwritten with the new
weekly reports.docxfile which was put in
C:\Reports\folder more recently.
- A file with the same name (
weekly reports.docx) as the day before is put into
C:\Reportsfolder on the next day (August 19th, 2020). Since files are moved to different backup folder each day, the file moving process will not be affected by existence of the file with the same name in different folder. In this case,
weekly reports.docxwill just be moved to
D:\Backup\2020-08-19\without regard to contents of
How to setup hourly backup folders instead of daily ones? If we wanted to create backup archive on hourly basis instead of daily one, we would need to add hour value to destination folder specification.
To modify already existing setup, go to the File tab of Move File Action properties, put a cursor at the end of the Destination input line, just after
D:\Backup\Date\ and click on Variable Wizard button. Choose Component from Date & Time category.
Select Hours (24) on the right side. The hour value is chosen in 24 hour format to enable easier folder sorting afterward. Click OK to return to the File tab of Move File Action. Add backslash character after
D:\Backup\Date\Date to specify that the destination will be a folder, not file. The final content of the Destination input line, thus, will be:
With this setup, the backup folder of each day will contain subfolders with hour number in their names. Or, the other way around, an hour subfolder will be created for each hour when a file is moved from
C:\Reports\ to backup folder.
For example, if some files are moved on August 18th, 2020 at the following times 10:12AM, 1:27PM and 3:59PM, the respective subfolders
15 are created in
Alternatively, instead of using
D:\Backup\Date\Date\ destination, it is possible to specify
D:\Backup\Date-Date\ folder as Destination. As a consequence, there will be no hourly subfolders for each date, but hourly folders containing Year-Month-Day-Hour in their names (e.g.
In this case, if some files are moved on August 18th, 2020 at the following times 10:12AM, 1:27PM and 3:59PM, the
2020-08-18-15 respective folders are created in
Assistance is here…
If you have any questions, please do not hesitate to contact our support team.