web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create file action fai...
Power Automate
Answered

Create file action fails in Power Automate due to long file path – how to shorten or fix it?

(1) ShareShare
ReportReport
Posted on by 4

I'm using Power Automate to save files from Microsoft Forms into SharePoint folders.

 

However, the Create file action fails with the error:

"The specified file or folder name is too long. The URL path for all files and folders must be 400 characters or less."

 

I'm using a dynamic file name that comes from the uploaded file, and I believe it's too long.

 

How can I safely shorten the file name or avoid this issue altogether?

Is using guid() a good solution, or should I truncate the original name?

P.S: I’m also including a screenshot of the full file path used in my Case 1 inside the Switch control, in case it helps clarify the issue.

Thanks in advance!

 

Screenshot 2025-07-09 165005.png
Categories:
I have the same question (0)
  • Verified answer
    Riyaz_riz11 Profile Picture
    4,048 Super User 2026 Season 1 on at
    HI,

    Option 1: Use guid() for the File Name (Most Reliable)

    This is often the cleanest approach:

    Why?

    • guid() produces a short, unique identifier (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

    • You avoid any risk of exceeding limits.

    • You can still store the original file name in metadata columns if you need to reference it.

    Example filename:

    guid() & '.pdf'
     
    guid() & '_' & split(triggerOutputs()?['headers']['x-ms-file-name-encoded'],'.')[1]

    (to preserve the original extension)

    How to set this in the Create File action:

    • File Name:

      guid() & '.pdf'

    •  

    or if you want to preserve extension dynamically:

    guid() & '.' & last(split(triggerBody()?['name'],'.'))
     

     Benefits:

    • Guaranteed unique.

    • Always short.

    • No path length issues.

     Option 2: Truncate the Original File Name

    If you prefer to keep a recognizable part of the filename, truncate it:

    Example:

    substring(triggerBody()?['name'],0,50)
     

    This keeps the first 50 characters.

    To preserve the extension:

    substring(first(split(triggerBody()?['name'],'.')),0,50) & '.' & last(split(triggerBody()?['name'],'.'))

     This reduces length while retaining readability.

     Option 3: Clean + Truncate + Unique Suffix

    Combine:

    • Clean filename (remove spaces/special characters)

    • Truncate

    • Add unique suffix

    Example expression:

    concat(
    substring(
    replace(replace(triggerBody()?['name'],' ','_'),'.','_'),
    0,
    30
    ),
    '_',
    guid(),
    '.pdf'
    )

     This results in a filename like:

    Report_Q1_2023_f2d9e7b2-3a1f-43c1-b334-2ab91c242ff9.pdf
     

    Much safer for SharePoint URLs.

    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard