cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gary111
Regular Visitor

Search and delete within sub folders for 100+ files

Hello,

 

I am trying to find a way to search for files and delete them along a path that has several folders and subfolders. 

 

Consider the following folder structure:

Root\Test\Read\User1, User2, User3, etc\subfolders\more subfolders

 

I have tried two methods to achieve this:  List Files in OneDrive Business and Search for files using path OneDrive for Business.  The list option does not recourse beyond the first folder and the search option works but has a limit of 100 results (I suspect that there will be more than 100 files once the project has started).

 

I would like to delete any file that is found that is more than 30 days old and whose  name does not start with "archive_".  Before the file is deleted, I would like to append a text log with the date and file path.

 

I got all of these parts to work as long as there are not too many subfolders or the search result returns less than 100 results.  I would appreciate any help on how to overcome these limitations.

 

Thank You,

Gary

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Gary111 :

I suggest creating a do until loop until all eligible files are deleted:

vbofengmsft_0-1632289827838.png

vbofengmsft_1-1632289844228.png

Best Regards,

Bof

 

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @Gary111 :

I suggest creating a do until loop until all eligible files are deleted:

vbofengmsft_0-1632289827838.png

vbofengmsft_1-1632289844228.png

Best Regards,

Bof

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,099)