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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Rename files automatically in OneDrive for business getting the folder name as a prefix

(0) ShareShare
ReportReport
Posted on by 14
Dear all, I am trying to create a flow where a file, which is saved in a OneDrive for busines folder is renamed and gets the name of the folder as a prefix.
Example: The folder is called "12259G1515" and the file is called "zk.pdf". When I drop the file in the folder, I would like it to have the name "12259G1515-zk.pdf".
 
I tried various ways, but unfortunately it did not work out. Does someone have an idea how the flow might look like?
I have the same question (0)
  • Verified answer
    v-zhoqian-msft Profile Picture
    Microsoft Employee on at
    Re: Rename files automatically in OneDrive for business getting the folder name as a prefix

    Hi @Hauke_Pay,

     

    You could refer to the following flow:

    vzhoqianmsft_0-1680765077650.png

    Expression:

    split(triggerOutputs()?['body/Path'],'/')
    concat(variables('arr')[sub(length(variables('arr')),2)],'-',last(variables('arr')))

     

    We can separate the path of the file into an array with "/", and concatenate the penultimate and last items into new file name.

    vzhoqianmsft_2-1680765724914.png

     

     

     

    Best Regards,

    Community Support Team _ habsburg Qian

    If this post helps, then please consider Accept it as the solution to help the other members find it.

     

     

     

  • Hauke_Pay Profile Picture
    14 on at
    Re: Rename files automatically in OneDrive for business getting the folder name as a prefix

    Hi @v-zhoqian-msft ,

     

    thanks for the reply. The flow looks very good. Unfortunately I cannot find compose/compose2 in my actions. Do you know what the problem is?

    1.png

  • v-zhoqian-msft Profile Picture
    Microsoft Employee on at
    Re: Rename files automatically in OneDrive for business getting the folder name as a prefix

    Hi @Hauke_Pay ,

     

    It seems that you are not using the English version, so you may not be able to search for 'Compose' action. You could search for the name of the action in your language or switch to the English version.

     

    Best Regards,

    Community Support Team _ habsburg Qian

    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • Hauke_Pay Profile Picture
    14 on at
    Re: Rename files automatically in OneDrive for business getting the folder name as a prefix

    Hi @v-zhoqian-msft,

     

    I almost got it. I built the flow but now I am getting an error. Please see the attached screenshot.

    2.png

  • v-zhoqian-msft Profile Picture
    Microsoft Employee on at
    Re: Rename files automatically in OneDrive for business getting the folder name as a prefix

    Hi, @Hauke_Pay 

     

    It seems that the 'Initialize variable' did not obtain the value of file path. It is null.

    Could you share more details about your flow, such as the formulas in each action and the running results of each action.

     

    Best Regards,

    Community Support Team _ habsburg Qian

    If this post helps, then please consider Accept it as the solution to help the other members find it.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 647 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 350 Moderator

#3
developerAJ Profile Picture

developerAJ 256

Last 30 days Overall leaderboard