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.
Solved! Go to Solution.
It should be %TextList2[0]% in your Trim and Rename file action. Please try
@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.
Hi Ankesh, this is what I see when I use display message
What is the filename you are creating after doing this "adding a datetime"? via PAD script
I am using this function on Power Automate desktop:
@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:
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.
I have tried both, individually and stacked and am facing the same error.
It should be %TextList2[0]% in your Trim and Rename file action. Please try
It worked! Thank you. Can you please tell me why naming it %TextList2[0]% changed the outcome?
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.