HOW TO

Move items from a group to a folder using API for Python in ArcGIS Online

First Published: October 21, 2025
Last Published: April 16, 2026

Summary

In ArcGIS Online, there are no user interface (UI) options to filter and move all items owned by a specific user from a group to a folder in 'My content'. Each item must be selected manually before being moved. The ArcGIS API for Python automates the process of filtering items owned by the user in the group and moving them to a target folder.

Procedure

  1. Log in to ArcGIS Online with an organization account.
  2. Click Notebooks > My notebooks > New notebook > Standard.
  3. In the notebook, select Code from the drop-down list as the cell type.
  4. In the first cell, paste the following code to import libraries from the ArcGIS API for Python and authenticate the connection to ArcGIS Online:
from arcgis.gis import GIS

gis = GIS("Home")                              # makes a connection to the account you are logged into ArcGIS Pro with
print("Logged in as:", gis.users.me.username)  # display username of the account logged in
  1. After pasting the code, click Run this cell and advance Run this cell and advance icon to execute the cell before proceeding to the next step.
  2. In the second cell, paste the code below to move the items from the group to the folder in My content. Replace the necessary parameters with the required input.
group_name   = "YOUR TARGET GROUP NAME"           # Input your target group name
target_folder = "YOUR TARGET FOLDER NAME"         # Input your target folder in My Content
your_username = "YOUR USERNAME OF ACCOUNT USED"   # Input your username of account used 

# Search the target group in Groups
groups = gis.groups.search(query=f'title:"{group_name}"')  

# Display error message if unable to find target group
if not groups:
    raise ValueError("No group found. Confirm the group title (case/spaces) and your org/account.")

group = groups[0]        # Input the index position of your target group; For example, the first group in the list is index 0
items = group.content()  # retrieve items from the target group that you chose

# Search and retrieve the target folder in the My Content, display an error message if unable to retrieve the target folder
folder = gis.content.folders.get(folder=target_folder)
if folder is None:
    raise ValueError(f'Folder "{target_folder}" not found in My Content.')


# Move the items from the target group to your target folder and display a message to inform the user what items were moved and to which folder
move = 0
move_title = []
for item in items:
    if item.owner == your_username:
        item.move(folder)
        print(f'✅ Moved: "{item.title}" → "{target_folder}"')  # Display all items moved and target folder
        move += 1                                               # this is a loop function to check and display all items moved
        move_title.append(item.title)

# Display total items moved from the target group to the target folder and a message if no items are move
print(f"\nSummary: moved {move} item.")
if move_title:
    print("Items moved:", ", ".join(move_title))
else:
    print("No items were moved (none matched your username).")

Below is the full working script.

from arcgis.gis import GIS
gis = GIS("Home")                              # makes a connection to the account you are logged into ArcGIS Pro with
print("Logged in as:", gis.users.me.username)  # display username of the account logged in
      
group_name   = "Test Script Group"           # Input your target group name
target_folder = "MovedFromGroup"             # Input your target folder in My Content
your_username = "TestingUsername"     # Input your username of account used 

# Search the target group in Groups
groups = gis.groups.search(query=f'title:"{group_name}"')  

# Display error message if unable to find target group
if not groups:
    raise ValueError("No group found. Confirm the group title (case/spaces) and your org/account.")

group = groups[0]  # Input position of your target group from the Groups tab, if in row 1, input '0'
items = group.content()  # grabs items from the target group that you chose

# Search and get the target folder in the My Content, display error message if unable to get target folder
folder = gis.content.folders.get(folder=target_folder)
if folder is None:
    raise ValueError(f'Folder "{target_folder}" not found in My Content.')

# Move the items from the target group to your target folder and display the output
move = 0
move_title = []
for item in items:
    if item.owner == your_username:
        item.move(folder)
        print(f'✅ Moved: "{item.title}" → "{target_folder}"')  # Display the title of all items moved and target folder
        move += 1                                               # this is a loop function to check all items moved
        move_title.append(item.title)

# Display total and the title of the items moved from target group to target folder
print(f"\nSummary: moved {move} item.")
if move_title:
    print("Items moved:", ", ".join(move_title))
else:
    print("No items were moved (none matched your username).")

The output displays the total number and titles of the items moved from the target group to the target folder.

Output displayed in the ArcGIS Notebooks cell
  1. Click Save as > Save notebook and close the notebook.
  2. Click Content > My content.
  3. Under Folders, click the folder. In this example, it is the MovedFromGroup folder.
The target folder in My Content

The items moved from the group are displayed in the folder.

Items transferred from the target group

Article ID: 000038681

Software:
  • ArcGIS Online
  • ArcGIS API for Python

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options