HOW TO
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.
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
to execute the cell before proceeding to the next step.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.


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

Article ID: 000038681
Get help from ArcGIS experts
Start chatting now