cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DarrenPlant
Helper II
Helper II

Renaming file after approval based on folder name

Having watched and learnt the simple approval float from Jon Levesque & Ashley Rogers, which is great. I am happy the approval piece of my workflow runs fine.  BUT, the problem is trying to rename the file based on folder.

 

approvals flow.png

 

My folders under Product & Solution Info library, the setup of folders are as follows:

 

/ProductA/00_ForApproval

/ProductA/99_Published

/ProductB/00_ForApproval

/ProductB/99_Published

........

/ProductG/00_ForApproval

/ProductG/99_Published

 

So the initial condition watches for any file posted to "/ProductX/00_" folder where "X" can be any Product folder - A,B,C..... the resultant file moves to a fixed named folder and performs the approval process, but remains as the same filename.

 

What I would like to do:

 

If file comes in to /ProductB/00_ForApproval/ folder, the file should move to /ProductB/99_Published.  If file is approved in the process, it gets marked as Approve.

 

File needs to be renamed from "ProductB-AAB.txt" to "ProductB-VN-AAB.txt" 

 

Issues:

 

With the move file I cannot seem to figure out how to apply a similar condition to move the file to the corresponding 99_Published folder and then how to rename based on the incoming format of the file.

 

Appreciate the guidance.

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @DarrenPlant 

 

There is no direct rename function available so you need to create the file and delete the original file. Please follow the below steps. 

 

image.png

 

Above expression for the replace is as follows:

replace(outputs('Compose'),'00_ForApproval','99_Published')

 

image.png#

 

Above Get File Properties > Id is triggerOutputs()?['body/ID']

Get File Content File > Identifier is outputs('Get_file_properties')?['body/{Identifier}']

Create File >"folderPath""@outputs('TargetPath')",

                    "name""@outputs('Get_file_properties')?['body/{FilenameWithExtension}']",
                    "body""@outputs('Get_file_content')?['body']"

 

Finally the Delete identifier is outputs('Get_file_properties')?['body/{Identifier}']

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

4 REPLIES 4
krootz
Solution Supplier
Solution Supplier

@DarrenPlant To rename, you will have to create a copy of the file in the target folder, then remove the original from the source folder. 

 

See link https://powerusers.microsoft.com/t5/General-Power-Automate/Renaming-a-File-in-SharePoint-Online-usin... 

abm
Super User
Super User

Hi @DarrenPlant 

 

There is no direct rename function available so you need to create the file and delete the original file. Please follow the below steps. 

 

image.png

 

Above expression for the replace is as follows:

replace(outputs('Compose'),'00_ForApproval','99_Published')

 

image.png#

 

Above Get File Properties > Id is triggerOutputs()?['body/ID']

Get File Content File > Identifier is outputs('Get_file_properties')?['body/{Identifier}']

Create File >"folderPath""@outputs('TargetPath')",

                    "name""@outputs('Get_file_properties')?['body/{FilenameWithExtension}']",
                    "body""@outputs('Get_file_content')?['body']"

 

Finally the Delete identifier is outputs('Get_file_properties')?['body/{Identifier}']

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
DarrenPlant
Helper II
Helper II

@abm Thank you so much, I was struggling to get my head around compose expressions.  Your detailed explanation was a massive help to me 😎.  If it was take one file and move, then rename, I was close to that.  But when you add in complexity of checking across mutliple directories, reading that directory to publish to an adjacent directory in that tree, that's when life came difficult, but you came to the rescue.  Thanks for being part of this community!

abm
Super User
Super User

Hi @DarrenPlant 

 

Thanks for the confirmation and glad to hear that you resolved your issue. This is one of the best community and there are lots of knowledge around.

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,491)