Automate Gsuite: Handle file conversion and send warnings when wrong formats are found

We are going to describe in here an automation idea that can be build in Studio Web with the help of UiPath.Gsuite.Activities.

Context: What mundane task are we to automate?

Chances are that your company has already a bunch of automations in place. And if the main processes that are automated are around file handling, then most probably your automations can handle specific types of file formats, and would break if the wrong format type is given as input.

We know for sure one thing: if you use Excel activities, you will need Excel type of files. If I give you PDFs, your automation won’t work.

Good news is that you can now avoid breaking your automations, by taking an additional preparation step: have another automation that preliminarily verifies on the files format, and if they are of a wrong format, then convert them as needed.

For best results, make sure to have it always run first, before the commencement of other automations. :wink:

Automation Steps

Step 1 - Go through all files within a folder

In order to verify each file in a folder, use the activity For Each File/Folder from the package Gsuite, which will iterate through the files in the indicated Google Drive location.

For this, you need only the Google Drive connection, and to browse, then select the exact folder path under the Location field.

All the sequent activities will be added in the body of For Each File/Folder activity.

Step 2 - Check all files’ extension for format type

Next step will be to check for the type of the files format. For this, select an ‘If’ condition from the System Activities package (in your workflow: click Add activity → Search by keywork “If”) Under this activity, you have the possibility to state a condition, that forks the outcome in 2 separate channels: Then and Else .

With the help of condition builder, configure the field Condition as GDriveRemoteitem.MimeType.Contains(“pdf”) :

  • GDriveRemoteItem’ is the value given by the For Each File activity during the iterations.
  • mimeType’ stands for type of the file.
  • Opt for the operator ‘contains’, so that there is some flexibility on the condition check time.

Under Then section , activities could be added to take action when the built condition is met. But for this automation, it’s expected to take no action if the files are pdf already. Thus, continue with workflow configuration on the Else section.

This is how you get to it:
2022-02-11_22h37_38

Step 3 - Download file and convert to .PDF

Though deletion would get rid of the non-PDF file, aim is to process all available files. So let’s convert the files, even if the risk is that data arrangement might be distorted afterwards.

Use Download File activity, which also has the option of downloading the files already as .PDF format. Files created on Google Drive are of Google type, thus the conversion option from the Download file activity will fit well for this case.

The only configurations needed are to indicate:

  • GDriveRemoteItem value for the File to download field.
    Where GDriveRemoteItem is the value given by the For Each File activity during the iterations.
  • A newly saved value ‘ convertedfile ’ for the Downloaded file field.
    This new value will be used in the upcoming activities.

Step 5 - Move file to a different folder

Once the non-PDF file has been downloaded and converted, the original file might not be needed anymore. But just to prevent data loss, you can keep them in a different folder, instead of deleting them. This way to ensure a file track for the course of actions taken.

To move the file from one folder to another, use Move File activity, where value GDriveRemoteItem should be indicated for the File to move field and the new folder destination for the Destination folder field.

Step 6 - Upload file back as .PDF

Now that the original files are removed from the main folder, the automations won’t break, but it is required to have the .PDF version of the files for processing the entire data pool.

Select Upload Files , and indicate the previously saved value ‘convertedfile’ for the Single File field, as well as for the folder path towards the location where it should reside.

Step 7 - Send email to inform of the actions taken

As anyone who uploaded the file has no way to know that he made a mistake by uploading the file in the wrong format type, neither that this led to the file conversion and removal. This is why you might want to inform the stakeholders of any action taken against the uploaded file(s).

For this, use the Send email activity, to send out an informative note every time a file is converted and removed.

One way of doing it, is to send the emails to a group email address, where everyone has access to. The group’s email address will be the recipient address.

It is also recommended to avoid creating the impression of spam when sending these emails, because it might result in people ignoring them at some point. That’s why, you can customize the email subject and body, so that it reflects exactly which file was deleted. This way by seeing the file name on every email, the file owners’ attention will be drawn and appropriate actions will be taken.

To achieve all the above mentioned, the activity fields are configured like this:

  • Group email address is indicated for To field
  • Custom subject title that contains the GDriveRemoteItem.FullName is indicated for Subject field
  • Custom body text that contains the GDriveRemoteItem.FullName is indicated for Body field
  • Save draft is set to False
  • Importance is set to High


Let us know what you think of this automation idea! Would you like us to share more of these?

  • Yes, more automation ideas please!
  • No, thank you.

0 voters