cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bluestone
New Member

Renaming Files in Sharepoint using Power Automate

Hi,

I have a system that generates a file regularly which is is the format STATIC_RANDOM.zip which contains two files STATIC_RANDOM.csv and STATIC_RANDOM_PARAMATERS.csv where STATIC is alway the name of the report and the Random characters change every time the report is run.  The report is emailed to me on a regular basis and I have automated it so it saves in a folder on sharepoint. A further flow then extracts the files from the zip into the same folder. I need to rename the files so they don't have the _RANDOM bit in the filename as I need to connect Power BI to the file and it needs the filename to be constant.
I think Substring might be an option ? but the location of the _ moves depending on the length of the report name
There will be a number of reports and I am struggling to get this to work, have read lots of articles which rename files but they expect the filename to be generally the same but  need a date adding on for instance. Any help would be greatly appreciated. 

Simon

Example of Sharepoint folder

Bluestone_0-1652697897094.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Bluestone ,

 

I did a test for you.

vxiaochenmsft_0-1652856505560.png

concat(substring(outputs('Compose'),0,indexOf(outputs('Compose'),'_')),substring(outputs('Compose'),indexOf(outputs('Compose'),'.')))
 
vxiaochenmsft_1-1652856535623.png

 

Best Regards,
Wearsky

View solution in original post

2 REPLIES 2
v-xiaochen-msft
Community Support
Community Support

Hi @Bluestone ,

 

I did a test for you.

vxiaochenmsft_0-1652856505560.png

concat(substring(outputs('Compose'),0,indexOf(outputs('Compose'),'_')),substring(outputs('Compose'),indexOf(outputs('Compose'),'.')))
 
vxiaochenmsft_1-1652856535623.png

 

Best Regards,
Wearsky

Hi, Thanks for this, it works absolutely as expected. The only issue i have now is that create the file works fine the first time but then fails to overwrite any subsequent time. Any thoughts ?

 

Simon

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,841)