Ershad Nozari
Ershad Nozari

Reputation: 667

Logic Apps SharePoint Connector - Move file with new file name

We have a integration requirement to move files from one folder to another in SharePoint Online. The new file name in the destination folder needs to be suffixed with the current datetime. For instance, if the source filename is Myfile.csv, it should be moved with the new name Myfile_2021-04-15T15:39:23.csv to the destination folder.

Using the Logic App SharePoint Move file action, I haven't been able to achieve this enter image description here

If another file is already there is an enum and I'm unable to provide a custom expression for it. Further, with this option files are only renamed if there's a file with the same name already existing in the destination folder. Whereas our requirement is to attach datetime to all files that are being transferred, independent whether the file already exist in the destination folder or not.

How can I best achieve this?

Thanks in advance for any assistance.

Upvotes: 1

Views: 1620

Answers (1)

Hury Shen
Hury Shen

Reputation: 15744

Since the "Move file" action doesn't provide a feature for us to specify the new file name, I think the requirement can't be implemented by this action. You can just use other action to do it.

For example, use "Get file content" action to get the file content.

enter image description here

Then use "Create file" action to create the new file in the location which you want.

enter image description here

You can specify a name which you want in the "File name" input box.

By the way, the "Get file content" action doesn't provide an expression of file name for us to use in second step. But I noticed that you have got Full path in your description, so you can substring the Full path to get the original file name. And then use utcNow() method to get the current date and append it to file name.

Upvotes: 2

Related Questions