How to determine file format from file content in Power Automate

When processing files in Power Automate, you may need to know a file’s format before determining how it should be handled. Whilst you can extract the format from the extension contained in the file name, you may want to instead get the file’s format based on its content. You can do this using Encodian Flowr’s Utility – Get File Format action in Power Automate.  

In this tutorial, we’ll build a Power Automate flow that runs when a document is added to a Documents to Process SharePoint library.

The flow will retrieve the file content, use Encodian Flowr’s Utility – Get File Format action to identify the file format, and check whether the file is a PDF. If the file is a PDF, the flow will send it for approval. If it isn’t, the user will receive a warning that the file doesn’t meet the required format. 

 

Try Flowr for Free More tutorials

You will learn

Using Flowr actions

Configure the Utility – Get File Format action in Power Automate

Why to use Utility – Get File Format

The difference between Utility – Get File Extension and Utility – Get File Format 

Downstream automation

Conditionally process documents based on the returned file format

Prerequisites for this tutorial

  1. A SharePoint document library to store the documents you want to process.

  2. A file to upload to SharePoint.

  3. An active Encodian Flowr subscription or trial.
    Not got a Flowr subscription? Start your free Flowr trial today →

Flow structure

When a document is added to SharePoint, the flow retrieves the file’s content, uses Encodian Flowr’s Utility – Get File Format action to identify the file format, and conditionally processes the file depending on the format. If the file is a PDF, the flow will send it for approval. If it isn’t, the user will receive a warning that the file doesn’t meet the required format.

When a file is created

Get file content

Flowr Logos

Utility – Get File Format

Return file’s format

Use returned data

Identify a file’s format from its content with ‘Utility – Get File Format’

1

Create a new automated cloud flow

Create new automated cloud flow

In Power Automate, create a new automated cloud flow.

2

Configure the trigger

Select the trigger and configure as follows: 

This flow will then run whenever a document is added to the Documents to Process SharePoint document library. 

3

Get the file content from SharePoint

To retrieve the binary contents of the file that has triggered the flow, add the Get file content SharePoint action. This content will then be provided as input for Encodian’s Utility – Get File Format action.

4

Add the 'Utility - Get File Format' action

To get the file’s format and corresponding file extension, add the Encodian Flowr Utility – Get File Format action to the flow.

5

Understanding the output of the ‘Utility – Get File Format’ action

examples of files and their result output from Utility - Get File Format

When the flow runs, Encodian Flowr’s Utility – Get File Format action returns the detected file extension in its Result output.  

6

'Get File Extension' vs. 'Get File Format'

The Utility – Get File Extension action processes a file name (a string value) and extracts its extension. For example, file.pdf would return a value of pdf.

However, a file name does not always represent the format of the underlying content accurately. A file may have no extension, and the file name may not be available in Power Automate.

The Utility – Get File Format action determines a file’s format from its binary content (the Power Automate File Content object). This approach is more reliable that relying on a file name, even when the file name is available.

To demonstrate this, the outputs when a file with no extension is processed with Encodian’s Utility – Get File Extension and Utility – Get File Format actions are shown below.

7

Conditionally process the file based on format

In this example, the flow checks whether the uploaded file is a PDF.  To perform this check, add a Condition to the flow.

In the True branch, add the Start and wait for an approval action and configure as required.

After the approval, add the Update file properties SharePoint action that will update the Status column to Approved upon approval.

8

Handle documents that aren't PDFs

In the False branch, add the Send an email (V2) Outlook action to notify users that the file is invalid.

9

Test the completed flow

Encodian Flowr’s Utility – Get File Format will identify the file format as pptx.

The condition checks whether the returned file format is pdf. In this case, the expression evaluates to False.

Email sent for an invalid document when testing with a ppt file

The flow follows the False condition branch, and sends an email to notify the user of the invalid file upload.

Next, add a PDF to the Documents to Process document library. Utility – Get File Format identifies its format as pdf.

Approval sent for new pdf document

The condition expression evaluates to True, starting an approval for the newly uploaded file.

Apprvoed document with status column changed to Approved

Once approved, the file’s status is updated in SharePoint to Approved.

Flow run when testing the flow with a pdf

FAQs

?

What is the difference between 'Get File Format' and 'Get File Extension'?

Encodian’s Utility – Get File Extension extracts the extension from a filename. Whereas Encodian’s Utility – Get File Format examines the file’s binary content, so is therefore useful when the file has no extension or when its filename does not accurately represent its content.

?

How do I process more than two file formats?

Use a Power Automate Switch action and select the Result from Utility – Get File Format as its input. Add a case for each format and use the default case to handle unsupported or unexpected files.

Troubleshooting

Below are solutions to common issues you may come across when building your flow.

Still struggling with your flow? Our Support Team would be happy to help!
Click the link below to raise a ticket on our support site.

Contact Support

Next steps

Once your flow can identify a file’s format from its binary content, you can extend the workflow to support more advanced file validation and processing.

  • Handle multiple file formats: Replace the Condition with a Switch action and create a separate case for each supported format, such as PDF, Word, Excel, PowerPoint, or image files.
  • Convert files to a standard format: If the uploaded file is not a PDF, use Encodian’s Convert – File to PDF action before sending it for approval. The action supports more than 70 document formats.
  • Compare the detected format with the filename: Use Utility – Get File Extension alongside Utility – Get File Format. If the filename says pdf but the binary content is another format, route the file for review.
  • Route files to different locations: Move each file into a format-specific SharePoint folder or document library. For example, send PDFs to an approvals library and images to an OCR process.

Or, try another Encodian tutorial to automate more document processing workflows:

More tutorials

Ready to automate file processing?

Start your free trial of Encodian Flowr for Power Automate to unlock over 250 actions for document automation.