Apply smart renaming for auto generated database files

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!

Overview. There is a system (legacy DB with custom scripts) in place, which generates daily reports for many departments. Generated pdf's are satisfactory, however their naming (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:

  • 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

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

First, use File / Folder watcher Trigger to monitor C:\Input\Files\ folder. In the Filter tab 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, specify 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 name - Report, 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 Actions - Split 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 - Date / 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 date - My 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 Actions - Split 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\ matching mask report-anything.pdf 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 / web server.

For example, see old name:

  • report-29051976-accounting.pdf

And notice the new one (the same file after smart renaming):

  • Accounting report 2019 May 13 - 0029051976.pdf

Now it is far easier to manage and overview PDF reports in a long term.

Free trial 15 day trial · Details…
Buy now 30 day MBG · Details…

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

© 2001–2019 Febooti Ltd.