
Hi @Slavík Jan ,
You could create a new SharePoint library then add one custom Date and time column named "End Date" to this library. Now you could create a Microsoft Power Automate Flow to auto lock this library by using "Grant access to an item or a folder" action.
For Example:
1.Create a new library and add "End Date" column(you also could add some other custom columns).
2.Now create Microsoft Power Automate Flow.
(1)Automate > Power Automate > See your flows
(2)New flow > Scheduled cloud flow > type flow name and select flow settings(repeat every 1 day)
(3)Add action > Get files(properties only) > select your site and library
(4)Add action > Apply to each > select value
(5)Add action in "Apply to each" > Condition > Choose "End Date" column "is equal to" "formatDateTime(addDays(utcNow(),1),'yyyy-MM-dd')
"( In this condiction code, number "1" is one day over end date, change if you need)
(6)if yes > add action > Grant access to an item or a folder > select site and library > select id > in "Recipients" type user name or group > in "Roles" select "can edit" or "can view" or "Enter custom value"
if no > add action > stop sharing an item or a file
The whole flow be like:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.