🧡 Skip to main content🔍 Skip to search
Matthew AdamsBy Matthew Adams 🕑 Updated on January 27, 2023 at 2:00 pm
YouTube video · Advanced file renaming

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!

Get the Demo Task…

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.

Folder Watcher: C:\Input\Files
Folder to watch: C:\Input\Files

First, using Split Text Action, we will tokenize monitored filename using dash character, to extract necessary parts from monitored file, namely id and department.

Split text filename
Split Text: Filename with dash

To automatically process every monitored file, choose Filename (without extension) using Variable Wizard · Triggers · File & Folder Watcher · Preset: Filename

Variable Wizard · Preset: Filename
Preset: Filename without extension

To simplify further Task creation, give each token a custom nameReport, EntryID and Department respectively. Later in this Task, we will use these names for easy token (separated & tokenized text) access.

Use custom token names
Use custom token names: Report, EntryID, Department

To capitalize the first letter of department token, use Change Text Case Action, and set case to Title Case.

Change text case to Title Case
Change Text Case: Department to Title Case

As a text string to capitalize, choose Variable Wizard · Actions · Split Text: Token 3 (with a custom name—Department).

Variable Wizard · Token: 3 Department
Variable Wizard · Split Text: Token 3

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).

Pad text left with 0
Pad EntryID with 0 and total length 10

At this point Task should contain 3 ActionsSplit Text, Change Text Case and Pad Text.

Creating Task · Watch for DB reports · 3 Actions
Creating the Task progress: Watch for DB reports · 3 Actions

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.

Move file to D:\Output\To send\
Move file [Filename] to D:\Output\To send\ folder

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.

Set Variable: My report
Set Variable My report to Capitalized text

Second variable My date contains 3 date components. They look the same, but are different inside:

Set Variable: My date
Set Variable My date to [Year] [Month] [Date]

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.
Variable Wizard: Day of the month
Variable Wizard: Time component · Day of the month

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.

Set Variable: My ID
Set Variable My ID to padded text

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 dateMy ID and .pdf extension.

Rename file, for example: Accounting report 2019 May 13 ‐ 0029051976.pdf
Dynamically rename file, for example: Accounting report 2019 May 13 ‐ 0029051976.pdf

At this point Task is completed. It contains 1 Trigger—File & Folder Watcher, and 8 ActionsSplit Text, Change Text Case, Pad Text, Move File, Set Variable, Set Variable, Set Variable and Rename File:

Final Task: Watch for DB reports · 8 Actions
Final Task: Watch for DB reports · 8 Actions

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!

Seamless automation. Take a quick 90-second journey!

Have a question?

If you have any questions, please do not hesitate to contact our support team.