SharePoint Online loop and create subfolders

%3CLINGO-SUB%20id%3D%22lingo-sub-570609%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20loop%20and%20create%20subfolders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-570609%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20a%20SharePoint%20Online%20document%20library%20to%20store%20documents%20stored%20per%20client.%3C%2FP%3E%3CP%3EI%20have%20a%20document%20set%20for%20each%20client.%20In%20total%20I%20have%20more%20than%20500%20document%20sets%2C%20all%20containing%20the%20same%20folder%20structure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20document%20library%20is%20built%20up%20as%20follows%3A%3C%2FP%3E%3COL%3E%3CLI%3EClient%20A%3COL%3E%3CLI%3EInvoices%3C%2FLI%3E%3CLI%3ECorrespondence%3C%2FLI%3E%3CLI%3ETechnical%3C%2FLI%3E%3CLI%3Eetc.%3C%2FLI%3E%3C%2FOL%3E%3C%2FLI%3E%3CLI%3EClient%20B%3C%2FLI%3E%3CLI%3EClient%20C%3C%2FLI%3E%3CLI%3EClient%20D%3C%2FLI%3E%3CLI%3Eetc.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20create%20another%20folder%20at%20the%20second%20level%20(where%20Invoices%2C%20Correspondence%2C%20etc.%20reside)%2C%20named%20%22Projects%22%2C%20and%20inside%20that%20new%20folder%20just%20a%20few%20subfolders.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20do%20this%20automated%2C%20otherwise%20it%20would%20take%20me%20a%20lot%20of%20time.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20seen%20a%20few%20articles%20on%20the%20web%2C%20but%20I%20haven't%20found%20the%20exact%20same%20scenario%20yet.%20I%20know%20somehow%20this%20could%20be%20done%20using%20PowerShell%20and%20a%20%3CEM%3Eloop%3C%2FEM%3E%3F%20PnP%3F%20But%20I%20don't%20have%20enough%20knowledge%20and%20experience%20to%20adjust%20the%20solutions%20from%20the%20articles%20I%20found%20so%20it%20would%20fit%20my%20scenario.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20would%20be%20the%20best%20approach%20to%20accomplish%20this%3F%3C%2FP%3E%3CP%3EI%20hope%20that%20someone%20could%20help%20me%20out%20with%20this.%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20helping%20out!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3EJoost%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-570609%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-574667%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20loop%20and%20create%20subfolders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-574667%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20meanwhile%20I%20have%20found%20a%20usable%20PnP%20script%20for%20this.%20I%20will%20include%20it%20below%20for%20future%20reference%20and%20try%20it%20out.%20I%20have%20attached%20the%20example%20script.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1920225%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20loop%20and%20create%20subfolders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1920225%22%20slang%3D%22en-US%22%3EThanks%20Joost%20Van%20der%20Linden.%3CBR%20%2F%3EThis%20saves%20me%20a%20lot%20of%20time%20to%20create%20one.%3C%2FLINGO-BODY%3E
Occasional Contributor

Dear all,

 

I am using a SharePoint Online document library to store documents stored per client.

I have a document set for each client. In total I have more than 500 document sets, all containing the same folder structure.

 

The document library is built up as follows:

  1. Client A
    1. Invoices
    2. Correspondence
    3. Technical
    4. etc.
  2. Client B
  3. Client C
  4. Client D
  5. etc.

 

I would like to create another folder at the second level (where Invoices, Correspondence, etc. reside), named "Projects", and inside that new folder just a few subfolders.

 

I would like to do this automated, otherwise it would take me a lot of time. 

I have seen a few articles on the web, but I haven't found the exact same scenario yet. I know somehow this could be done using PowerShell and a loop? PnP? But I don't have enough knowledge and experience to adjust the solutions from the articles I found so it would fit my scenario.

 

What would be the best approach to accomplish this?

I hope that someone could help me out with this.

Thanks in advance for helping out!

 

Kind regards,

Joost

2 Replies

In the meanwhile I have found a usable PnP script for this. I will include it below for future reference and try it out. I have attached the example script.

Thanks Joost Van der Linden.
This saves me a lot of time to create one.