Automation Workshop helps to automate everyday tasks of any complexity. Do you need to watch some folder for changes? Execute the same backup process every other day? Process files based on their type or content? Something else…? Automation Workshop will hit the nail on the head. Effortlessly!
Overview
Suppose there is a system (legacy DB with custom scripts) in place, which generates daily reports for many departments. Generated PDFs are satisfactory, however their naming (actual file name) provides little to no value, and is hard to manage in long term. Imagine thousands of files with the following naming scheme: report-id-department.pdf, for example:
- report-29051976-accounting.pdf
- report-210776-sales.pdf
- report-1103-marketing.pdf
The goal
We will automatically convert file name and store these reports based on their creation date and department:
- Accounting report 2019 May 13 ‐ 0029051976.pdf
- Sales report 2019 Oct 17 ‐ 0000210776.pdf
- Marketing report 2019 Sep 02 ‐ 0000001103.pdf
We are going to monitor a folder for any new PDF file using File Watcher Trigger. The Trigger will start a Task, that will do the actual job—rename file using human readable file naming, while keeping the important details of original file name. Also, we will move the file to another location to allow easier file management.
Solution
First, use File & Folder Watcher to monitor C:\Input\Files\
folder. And set an include mask to required format, in our case, report-*.pdf
mask that will trigger the actual Task execution.
First, using Split Text Action, we will tokenize monitored filename using dash character, to extract necessary parts from monitored file, namely id and department.
To automatically process every monitored file, choose Filename (without extension) using Variable Wizard · Triggers · File & Folder Watcher · Preset: Filename
To simplify further Task creation, give each token a custom name—Report, EntryID and Department respectively. Later in this Task, we will use these names for easy token (separated & tokenized text) access.
To capitalize the first letter of department token, use Change Text Case Action, and set case to Title Case.
As a text string to capitalize, choose Variable Wizard · Actions · Split Text: Token 3 (with a custom name—Department).
Same length tokens are easier to overview and manage. To unify ID value (make it the same uniform length, regardless of its initial value), use Pad Text Action—Pad with 0, and set total length to 10. As a text string specify Variable Wizard · Actions · Split Text: Token 2 (with a custom name—EntryID).
At this point Task should contain 3 Actions—Split Text, Change Text Case and Pad Text.
Now we are ready to move watched file to the new location D:\Output\To send\
, and rename it according to our requirements. First, move file, using Move File Action. As a Source use Variable Wizard · Triggers · File & Folder Watcher · Preset: Full path and filename.
Custom variable names make a task management easier in future. Thus, before renaming a file, we will prepare 3 variables (My report, My date, My ID) using Set Variable Action, each containing essential part of new file name. Variable My report contains Variable Wizard value · Actions · Change Text Case: New capitalized text. And simply the word—report.
Second variable My date contains 3 date components. They look the same, but are different inside:
Use Variable Wizard Date & Time category, Component subcategory and choose the following values:
- Year
- Month (text)
- Day of the month; and enable Add leading zero option.
Third variable My ID contains only one Variable Wizard value · Actions · Pad Text: New padded text. This will make the final rename operation straight forward.
Finally, to rename file, use Rename File Action. As a source (Old name) use Variable Wizard value · Actions · Move File: Last destination file. For New name combine all 3 variables: My report My date ‐ My ID and .pdf extension.
At this point Task is completed. It contains 1 Trigger—File & Folder Watcher, and 8 Actions—Split Text, Change Text Case, Pad Text, Move File, Set Variable, Set Variable, Set Variable and Rename File:
Summary
From now on, any new PDF file in folder C:\Input\Files\
automatically will be moved to folder D:\Output\To send\
, and will be smartly renamed, keeping the meaning of file.
To make everything work automatically, and to pass data from one Action to another, we use Variable Wizard. Further, these newly renamed files are ready to be sent via email as attachments, or synced to storage or web server. For example, see old name:
- report-29051976-accounting.pdf
…and notice the new one (the same file after intelligent renaming):
- Accounting report 2019 May 13 ‐ 0029051976.pdf
Now it is far easier to manage and overview PDF reports in a long term!
Have a question?
If you have any questions, please do not hesitate to contact our support team.