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 / Can't rename file in a...
Power Automate
Unanswered

Can't rename file in a loop

(1) ShareShare
ReportReport
Posted on by 10

The problem I am trying to resolve is to print several different documents to PDF files, and then merge them into one PDF file.

 

My method:

With PDF Printer as the default printer, I set up a loop for Word files, and one for Excel files.

Within each loop, for each CurrentItem, I get the file path name (to name the interim PDF file), and rename each file to one consistent name (e.g., ToPrint.docx or ToPrint.xlsx) so that I can populate the interim filename and save the interim files via the UI element with the same Word and Excel windows 

 

However, after the first run of the loop, I cannot rename the file in the second run of the same loop.  The error message is "Can't rename file" because access to path of ToPrint.docx is denied.

 

 

  • fraenK Profile Picture
    2,125 on at

    You don't need to rename the files, just store the file name in a variable and use this in the selector to get the application window 

  • NercyCrab Profile Picture
    10 on at

    Thanks for your advice.  However, I still have the following issue to resolve:

     

    Let's say the files may be docx or xlsx or else.  If I have set the printer to PDF Printer, after "Print document", I will have to "Populate text field in window" for the "File name" text box.  How can I properly identify the window?

  • fraenK Profile Picture
    2,125 on at

    Normally it should be part of the selector, but you can also get or focus the window based on its title

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard