79200702

Date: 2024-11-18 16:36:19
Score: 3
Natty:
Report link

So it sounds like you need to essentially duplicate the contents of a document library from one SharePoint site into another, excluding PDFs. The setup you have now is good all you really need to do is add another condition that checks whether the items is a folder or not, and then create the file/folder appropriately. Luckily, a recursive solution is not necessary.

The following is a general description of a flow that will copy all files (including folder structure and excluding PDFs) from one SharePoint site's document library to another SharePoint site's document library:

  1. Your flow's trigger
  2. Initialize varibale
    • Name = strTemplateLibraryName
    • Type = String
    • Value = <the name of the document library you are copying files from>
  3. Initialize variable
    • Name = strTargetLibraryName
    • Type = String
    • Value = <the name of the document library you are copying files to>
  4. Get files (properties only)
    • Site Address = <the URL of the site you are copying files from>
    • Library Name = strTemplateLibraryName
  5. Apply to each
    • Input = outputs('Get_files_(properties_only)')?['body/value']
  6. Condition (inside Apply to each)
    • items('Apply_to_each')?['{IsFolder}'] is not equal to true

The false branch of your Condition will be all iterations where the item is a folder and should have this structure:

  1. Compose (FullFolderPath)
    • Inputs = items('Apply_to_each')?['{FullPath}']
  2. Compose (FolderPath)
    • Inputs = last(split(outputs('FullFolderPath'), variables('strTemplateLibraryName')))
  3. Create new folder
    • Site Address = <the URL of the site you are copying files to>
    • List or Library = <the document library you are copying files to>
    • Folder Path = outputs('FolderPath')

The true branch of your Condition will be all iterations where the item is a file and should have this structure:

  1. Condition
    • whatever your existing condition is to check if the file is a PDF
    • if the file is not a PDF, continue steps below, else ignore
  2. Compose (FullFilePath)
    • Inputs = items('Apply_to_each')?['{FullPath}']
  3. Compose (FilePath)
    • Inputs = first(split(last(split(outputs('FullFilePath'), variables('strTemplateLibraryName'))),item()?['{FilenameWithExtension}']))
  4. Get file content
    • Site Address = <the URL of the site you are copying files to>
    • File Identifier = items('Apply_to_each')?['{Identifier}']
    • Infer Content Type (parameter) = Yes
  5. Create file
    • Site Address = <the URL of the site you are copying files to>
    • Folder Path = /variables('strTargetLibraryName')outputs('FilePath')
    • File Name = items('Apply_to_each')?['{FilenameWithExtension}']
    • File Content = body('Get_file_content')

When I made this flow a while back, I was referencing this guide that you might find helpful. It is difficult to write out flows on here so please let me know if you have any questions.

Reasons:
  • Blacklisted phrase (1): this guide
  • RegEx Blacklisted phrase (2.5): please let me know
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: beelow