cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pkositz
Frequent Visitor

Can't Rename File Error

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.  

1 ACCEPTED SOLUTION

Accepted Solutions
Ankesh_49
Super User
Super User

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

View solution in original post

10 REPLIES 10
Ankesh_49
Super User
Super User

@pkositz  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.

 

pkositz
Frequent Visitor

pkositz_0-1658770627516.png

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

Ankesh_49
Super User
Super User

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

pkositz
Frequent Visitor

I am using this function on Power Automate desktop:

 

pkositz_0-1658772793107.png

 

Ankesh_49
Super User
Super User

@pkositz  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.

pkositz
Frequent Visitor

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

pkositz_0-1658775185633.png

 

pkositz_1-1658775201124.pngpkositz_2-1658775310900.png

 

Ankesh_49
Super User
Super User

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

Ankesh_49
Super User
Super User

@pkositz  Any luck?

pkositz
Frequent Visitor

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

Ankesh_49
Super User
Super User

@pkositz 

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.

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.

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 (4,467)