Activities
latest
false
Banner background image
Productivity Activities
Last updated Apr 26, 2024

For Each File or Folder

UiPath.MicrosoftOffice365.Activities.Files.ForEachFileFolderConnections

Description

Iterates through a list of files and folders from OneDrive or SharePoint.

Add the activities to repeat inside For Each File/Folder and, when you configure the activities, select Use Variable > CurrentItem from the See more button menu to indicate that you want to repeat the actions for each item in the iteration.

Note: This activity uses pagination for processing large numbers of items and mitigating performance issues. This activity doesn't support persistence.
Important: The Microsoft Graph API doesn't differentiate between Folders and OneNote files, so both will be returned.
Scopes

This activity requires the following scopes:

  • Files.Read
  • Files.ReadWrite
  • Files.Read.All
  • Files.ReadWrite.All
  • Sites.Read.All
  • Sites.ReadWrite.All

Project compatibility

Windows | Cross-platform

Configuration

  • Microsoft OneDrive & SharePoint connection - The connection for the Microsoft 365 account to use in the activity.
  • In location - The location where to search for files and folders. The method to specify the file or folder to be retrieved: Enter Id, Enter Url or Use variable.
    • Folder picker option - Browse the OneDrive or SharePoint folders and select a file or folder. This field accepts IResource input.
    • Enter Id option:

      • File or folder Id - The ID of the file or folder. To retrieve the ID, open the file in OneDrive Web and retrieve its URL. The ID is encoded in the URL. For example: if the URL is https://yourcompany.sharepoint.com/Doc.aspx?sourcedoc=%7BA1CA7E78-BA59-4DD4-A6B9-5F5BBC37FA85%7D&file=Merge_sheets.xlsx`, the decoded file ID is A1CA7E78-BA59-4DD4-A6B9-5F5BBC37FA85. %7B and %7D are the delimiters around the file ID. This property supports String variables and string formatted values.
      • SharePoint site address - The URL of the SharePoint site that contains the file or folder. Open your SharePoint site in a browser and retrieve the URL, e.g., https://yourCompany.sharepoint.com/sites/Marketing. This property supports String variables and string formatted values.
      • SharePoint document library - The document library within the indicated SharePoint site that contains the file or folder. Open your SharePoint site in a browser, go to the Documents tab, then retrieve the URL, e.g., https://yourCompany.sharepoint.com/sites/Marketing/Shared%20Documents/Forms/AllItems.aspx. This property supports String variables and string formatted values.
    • Enter Url option:

      • File or folder Url - The URL of the file or folder. Open the file or folder in the browser and retrieve its URL. This property supports String variables and string formatted values.
    • Use the See more button menu to use a variable or select the Reload Folder Picker option if you've modified your folders and need to retrieve the latest data.

Additional options

Options

  • Limit to first - The maximum number of files and folder to return. If left blank, there is no limit. This field supports Int32 variables and Int32 values.
  • What to return - The types of results to return: both files and folders, only files, only folders.
  • Trim duplicates - Boolean value. Set to True to remove duplicate files and folders from the search results.
  • Simple search - The query text used to search for files and folders across several fields (such as file name or file content). This property supports String variables and string formatted values. Use the See more button menu to switch to Advanced search.
    Note: Simple Search is available for Business Accounts and Personal Accounts. Advanced Search is available only for Business Accounts and it includes the Include subfolders option.
  • Advanced search - An advanced search criteria defined to filter the files and folders. This option isn't supported for personal Microsoft accounts. Advanced search uses the Filter builder to configure the search criteria.

    • Include subfolders - Boolean value. Set to True to expand the search to all subfolders in the selected location.

Output

  • Total number of files or folders processed - The total number of items processed by the activity. Can be used outside the For Each File/Folder activity. Automatically generated output variable. You can use it as it is or save it with a different name.
Body

The body of the activity that stores other activities used in the automation.

Filtering limitations
  • Filtering by File extension in the Filter builder might not work for extensions such as .avi, .svg, .gif, .ico, .jpeg, .jpg, .mov, .mp3, .mp4, .ogg, .png, .rtf, .tiff, .wav, .webm, .webp, or .wmv.

  • Filtering by Last modified by or Shared with user might return incomplete results.

  • The Graph API trims special characters from the beginning of a searched value. For example, if you search for "_Sorted", the API returns all files/folders whose name contains the word "Sorted", omitting the "_" character.

  • When iterating through files in the OneDrive root folder using Advanced search without any filters configured and even when Include subfolders is False, the activity may return all OneDrive files instead of just the OneDrive root folder’s files only.
  • Due to a Microsoft limitation, Simple search doesn't identify image files. Use Advanced search instead, filtering by: File or folder name contains .jpg.
Note:

Batching API calls is supported for the following activities when used inside the For each:

Example



See also:
  • Description
  • Project compatibility
  • Configuration
  • Example

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.