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

 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Users online (2,459)