
Before I go into details, you should know that I got this working using out of the box SharePoint 2016 on-prem running Designer 2013 and using a 2013 Workflow.
Nothing extra was needed, copying files to different folders can be done with out of the box Designer 2013 workflow features. This was music to my ears since it is important functionality and should not rely on non-stock features.
Also note that at this time SharePoint online has more modern ‘flows’ using Power Automate and that these will have quite different syntax and functionalities, but in this case I am working with older technologies.
So all of this is good news if you’re looking at implementing something similar of copying files to folders using a SharePoint designer 2013 workflow. It’s possible out of the box, but just not well documented how to get it to work.
Read more: SharePoint Designer Workflow Copy File to Folder in the Same LibraryTo copy a file in a library from one folder to another folder:
In SharePoint Designer I pointed to the document library that I was working with. I then started a new workflow. After some looking around, the only option to do a file copy is in Workflow actions, add the action called ‘Update List Item‘
Getting this action to copy a file from one folder to another is a bit finicky and isn’t very intuitive to get working. I had to methodically test and write down each of my test cases when I was trying to get it to work and couldn’t find help articles online that worked.
In the end the solution was rather simple but not at all obvious. It’s all about the syntax of the path. If you enter it wrong you’ll see any number of errors, the least helpful of which I found to be:
The file or folder name contains characters that are not permitted. Please use a different name.
The most important point in getting this functionality to work is that the path can’t start with a forward slash. The path format for your destination folder is:
sub-folder1/sub-folder2/filename.txt
So for example, if you have a file and folder structure like this from your library, you’d use this syntax:
test/subfolder/filename.txt
This is non-intuitive since in other spots in SharePoint (such as the file upload window), a beginning forward slash is set when specifying a file folder path to upload to.
Since you are using the ‘path and name’ function you can also change the file name from here when you are specifying the file and path because you are updating the ‘current item’.
Steps to Set Up the Folder Copy:
- In Workflow actions, add the action called ‘Update List Item’
- In the Update List Item popup windows, choose
- List: Current Item
- Then click the ‘Add’ button and select to:
- Set this field: Path and Name
- To this Value: test/subfolder/filename.txt
Again, a big point to note is that there is no beginning slash in the Path field.
Some Extra Points
Here is some extra information that I found helpful while I was debugging my workflow.
In Designer Studio 2013 I made sure to only have my workflow trigger manually. This is a checkbox that you set on the main workflow configuration page in Designer Studio
To avoid issues with the workflow looping and triggering itself during the copying testing, I put an ‘if’ condition on the origin folder and file name so that the workflow would only trigger once. The ‘if’ condition looks like this:
If Current Item:Server Relative URL contains /abc/filename.txt
You can check the error message and force-stop your workflow instance if there are any issues. You can do this from the library itself. Make sure that you make the workflow column visible in your library. Then when you trigger your workflow on the document this column will show the stage as a click-able link.
If there is a problem reported on the workflow status page, there is a click-able ‘i’ button beside the Internal Status. If you click this you’ll see hopefully helpful debugging details.
Leave a comment