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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (5,065)