Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Automating File Renaming in SharePoint Folders Based on PDF Content Using Power Automate

Like (0) ShareShare
ReportReport
Posted on 12 Dec 2024 15:23:01 by

I’m working on a project to streamline file management within a SharePoint document library for a banking workflow. The library contains a large set of folders, each with files related to specific customers who have loans with the bank. These files have inconsistent and unstructured names, making it difficult to manage them efficiently.

My goal is to create a Power Automate flow that can:

  1. Loop through all the folders and process each file individually.
  2. Extract key information (e.g., customer name and loan number) from the content of each PDF file (there are many files in these folders that have no correlation to the information needed).
  3. Use the extracted information to rename the folder in a consistent format, such as CustomerName_LoanNumber.

I'm completely new to power automate and am looking for a faster solution to an otherwise resource heavy and annoying problem. Attached is an example of what content the folders would contain and what the power automate script would have to sift through to be able to get the information to rename the folder to the correct name. 

The example name and loan number are in the 201311_cfpb_kbyo_closing-disclosure file.

Any advice, best practices, or resources to achieve this would be greatly appreciated. Thanks in advance!

  • Suggested answer
    Ninjasabi Profile Picture
    120 on 13 Dec 2024 at 12:35:43
    Automating File Renaming in SharePoint Folders Based on PDF Content Using Power Automate

    Overview:

    Renaming SharePoint folders based on extracted content from PDFs is a complex task, but Power Automate, combined with AI tools like Azure Form Recognizer or other third-party connectors, can help streamline the process. Below are the key steps:


    Solution Outline:

    1. Pre-requisites:

    • Access to SharePoint and the document library with appropriate permissions.
    • An Azure subscription (for Azure Form Recognizer, optional but recommended).
    • Well-defined criteria for extracting the CustomerName and LoanNumber from PDF files.

    Step-by-Step Implementation:

    1. Trigger the Flow:

    • Use the "Manually trigger a flow" action to start the process or set up a scheduled flow (e.g., run daily).
    • Add a dynamic input for specifying the root folder of the SharePoint library (optional).

    2. List All Folders and Files in the Library:

    • Use the "Get files (properties only)" action to retrieve all files in the library.
    • Add a condition to filter files by extension (e.g., .pdf) to avoid processing non-PDF files.

    3. Extract Content from PDF:

    Power Automate doesn’t natively support PDF content extraction, so you’ll need to use an external service:

    • Option 1: Use AI Builder (Premium):
      • Use the "Extract information from documents using AI Builder" action.
      • Train a model to extract the CustomerName and LoanNumber based on your example files.
    • Option 2: Use Azure Form Recognizer:
      • Send the PDF to Azure Form Recognizer via an HTTP action.
      • Parse the JSON response to extract CustomerName and LoanNumber.
    • Option 3: Use a Third-Party Connector (e.g., Encodian or Plumsail):
      • These connectors allow you to extract text or specific information from PDFs.

    4. Build a Naming Pattern:

    • After extracting the required fields, construct the new folder name dynamically:
      concat(CustomerName, '_', LoanNumber)

    5. Rename the Folder:

    • Use the "Move file" action in Power Automate to rename the file:
      • SharePoint treats renaming as a "move" operation.
      • Specify the current folder path and provide the new folder name dynamically.

    Key Challenges and Workarounds:

    1. Inconsistent PDF Content:

      • Train an AI Builder or Azure Form Recognizer model to handle variations.
      • If certain PDFs don’t contain the required information, log these instances in a SharePoint list or Excel for manual review.
    2. Processing Large Libraries:

      • Use pagination in the "Get files (properties only)" action to handle more than 5,000 files.
      • Consider breaking the flow into batches if there are thousands of PDFs to avoid throttling.
    3. Error Handling:

      • Add a "Scope" for error handling and log failures in a SharePoint list or send an email notification.

    Example Flow Structure:

    1. Trigger:
      • Manually trigger the flow or schedule it to run at specific intervals.
    2. List files in folder:
      • Use "Get files (properties only)" to list all files.
    3. Filter PDF files:
      • Filter using a condition or direct query for fileExtension eq 'pdf'.
    4. Apply to each (PDF):
      • Extract content from each PDF using AI Builder or Azure Form Recognizer.
      • Construct the new folder name dynamically.
      • Rename the folder using the "Move file" action.
    5. Log Errors (Optional):
      • Use a parallel branch to log unprocessed files or folders.

    Tips:

    • Testing: Run the flow on a smaller dataset first to ensure it’s processing correctly.
    • Optimization: Use the "Filter Query" option in actions like Get files to reduce unnecessary processing.
    • Backup: Create a backup of your library before running the flow in production.

    Let me know if you need help setting up the flow or configuring AI Builder/Form Recognizer for this task! 😊

    Best regards,
    @Ninjasabi

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 101

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 60 Super User 2025 Season 1

Overall leaderboard