I have a collection of folders in SharePoint all within 1 folder. These folders have various files inside of them ranging from PDF to JPEGs. I need to move these files into a collection of lists items inside a different SharePoint folder. The transfer should occur when clicking the list item, or it should happen all at once (whatever is easiest).
The title of the folder must match with the transition ID of a list before a transfer can be made (i.e., contents of a folder whose title is 111 will have their files copied and pasted into the list with transition ID 111 as attachments).
I cannot post a screenshot of my flow attempt but I will explain it below:
Trigger: ‘For a selected item’ [list items]
‘Get items’ [from original folder]
’Filter array’ [where folder name must equal to list item transition ID]
’Apply to each’ [loop the function for each list item]
‘Create file’ [Create a copy of the files from the folder into their appropriate list item]
I am getting an error attempting to save, indicating that I may have invalid input parameters. How can I go about this task properly with appropriate input parameters in each action?
Hi @PCarti
May be give a try with this approach
Step 1: List all folders present in main folder like below
Step 2: Since List folders list all files and folder present in MainFolder, we need to get only the elements in the output json array which has folder details , so use the below filter array
(both dynamic contents are from list folder action)
Step 3: Loop through the output from Filter array using apply to each loop
Further steps below would be steps used under the loop
Step 3.1: use list folder action to list all files coming under subfolder under main_folder through which we are iterating
Step 3.2: Now we need to find ID of list item to which we need to attach the attachments, for that we will be using Get items filter query
Note: here i am using Title as identifier by which we identify required subfolder by its name and attach its contents/attachments
In your case if you are other columns apart from title as identifier, use appropriate column name instead of Title which i have used in Filter Query (That's all change is needed when you are designing the flow 🙂 , I think)
Step 3.3: Now check whether the list item having the required title value exists for attaching attachments, use condition for that like below
In the loop
a1. use get attachment content to get attachment content which is currently being iterated
a2. use add attachments action to add attachment to the list item
expression:
------------------------------------------------------------------------------------------------------------
This is how flow should be designed
Output was like this
In the folder, there were two files
After running flow, files were attached to sharepoint list
I hope this helps you !
Hi Nived,
Thank you very much for the response. I believe that it is close to the solution; however, I seem to be receiving an error from the 'List folder' expression stating that 'The response is not in a JSON format'.
Solutions that I have attempted but resulted in the aforementioned error:
(1) modifying folder names to the appropriate folder as suggested by you
(2) modifying 'Title' to 'ID' to closer match my needs
I have also tried remove the expression and to directly link 'Test Folder'; however, the flow then had an error at 'Get file content' as it could not find the file.
Furthermore, I'd like to clarify my goal which is to append content from one folder (which contains numerous .pdf, .jpg etc.) to a list item as attachments, but only if the folder's Title matches the list item's TransitionID. The TransitionID is a custom column but we can use a standard ID if that is easiest to demonstrate.
Ex. 1: folder '1' content will only transfer to list item '100A' whose TransitionID is '1'
Ex. 2: folder '5' content will only transfer to list item '200B-B' whose TransitionID is '5'
Ex. 3: folder '6' content will only transfer to list item '#300-C/C' whose TransitionID is '6'
Hi @PCarti
Sorry for late response !
Try like below
Assume you have main folder and subfolder inside it with title of list item as folder name like below
step 1: use trigger get select item
step 2: use get item to get the details of that list item which is selected.
step 3: use list folders to list all files in the folder whose folder name is name of title of list item
expression:
Rest steps would be steps used under the loop
Step 4 a: use get file content to get file content of that file.
Step 4 b: use add attachments to add that file as attachment to list
Hope this helps !
Mark it as solution if it resolves your query !
Hey there. I am trying to copy the items in the folder to the list as attachments. However, I want the transfer filtered by folder title and list transition ID. Let me know if I can clear up anything else!
Michael E. Gernaey
18
Super User 2025 Season 1
stampcoin
16
Churchy
12