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 Error
Power Automate
Answered

Can't Rename File Error

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello all,

 

This is my first time using power automate and I am trying to rename a file based on a clipboardtext. While I can rename the file by adding a datetime to the filename without any issue, when I try to set new name using the clipboard text I get this error:

 

Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Can't rename file ---> System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.RenameFilesAction.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.RenameFilesAction.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

 

The clipboard copies a line from an excel file and stores it just to rename the file in the folder. It does not contain any special characters that would stop the file from being renamed.

 

Any help would be appreciated.  

I have the same question (0)
  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    @Anonymous  Could you please use display message action and try to see which text is coming in clipboardtext variable.

    it may give us a clue about the issue you are encountering.

     

    Hope it helps!!

     

    Cheers,

    Ankesh

    --------------------------------

    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    pkositz_0-1658770627516.png

    Hi Ankesh, this is what I see when I use display message

  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    What is the filename you are creating after doing this "adding a datetime"? via PAD script

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am using this function on Power Automate desktop:

     

    pkositz_0-1658772793107.png

     

  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    @Anonymous  Since the text is getting copied from an excel cell. I believe there is a whitespace(in the beginning or the end of clipboard text) or newline in clipiboardtext.

     

    Therefore I would recommend you to use either Trim text action or Split text action. For example I have used Split text action:

    Ankesh_49_0-1658774584056.png

     

      

    Hope it helps!!

     

    Cheers,

    Ankesh

    --------------------------------

    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have tried both, individually and stacked and am facing the same error. 

    pkositz_0-1658775185633.png

     

    pkositz_1-1658775201124.pngpkositz_2-1658775310900.png

     

  • Verified answer
    AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    It should be %TextList2[0]% in your Trim and Rename file action. Please try

  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    @Anonymous  Any luck?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It worked! Thank you. Can you please tell me why naming it %TextList2[0]% changed the outcome? 

  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    @Anonymous 

    To retrieve a specific item of a list, we have to use the following notation: %VariableName[ItemNumber]%

    Keep in mind that the index should be 0 for the first item of the list.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard