In this particular article, we’re going to see such a scenario in which a user has full rights on the library is unable to delete the folder in SharePoint 2013 or in SharePoint Online.
Problem The file is currently checked out or locked for editing by another user in SharePoint
About the ProblemHello geeks, sometimes it becomes a little tricky to delete a folder in the SharePoint library.
In this particular article, we’re going to see such a scenario in which a user has full rights on the library but is unable to delete the folder in SharePoint 2013 or in SharePoint Online.

Or in the modern view, it’s something like:

Let’s start the journey.
In SharePoint, a user having full permission on the library, even is he/she is site collection admin, is unable to delete items just because that item is checked out by another user. But, what if he is unable to figure out by whom the item is checked ou?. So, here, we come to the problem with a good solution.
Let’s understand it by a scenario here.
A user created a library named Library1 and created a folder named Folder1.

Now, create a folder in Library1 named Folder1.

Now, the user has created a document in a document library.
Note: The tricky part comes into the picture now. By default, when a user creates a Library, it comes with versioning enabled. Somehow suppose that versioning is not enabled or manually disabled by the user at the time of creation, then the versions of the item will not be captured.
Sometimes, what happens is that when a user creates a document, it directly goes into the checked-out state without having version enabled in the list. So now, the document is in checked out state and doesn’t have a check-in version as the version was not enabled. This is called “Files with no checked-in version”.
So, let’s dig deeper into the problem and find the solution.
A user uploaded a document in Folder1 (created above).

Now, let’s check its version history.

So, we understand that versioning is enabled on the list. Now, the user checked out the document for editing purposes. Another user is still able to see the document in the checked-out state just because it has a version.

Let’s see another aspect of this scenario. Suppose versioning is disabled from the setting page of list/library.

Also, user enabled one more setting for checking out the document.

What is this setting all about? When a user creates a document, it directly goes into the checked-out state without having any changes which mean the user is now authorized to make changes before anyone else makes a change.
If you look in the ECB menu, the option related to versioning is not shown.
Now, user uploaded a new document and that document is directly checked out as required and checked out setting is enabled at the library level.

Now, let’s see when another user looks into the library.

Note – The first user who created the document checks in ImportTermSet.csv file.
Wow, another user can’t see a newly created document that was checked out at the time of creation by the first user (Asha in this case).
So when another user wants to delete Folde1, he/she gets the error.


So now, think how a user identifies which document is checked out by which user so that he can delete the unused folder.
So here is the solution. There is a setting in setting page –

Click on the setting above. The user is able to see how many documents in Libray1 are checked out that have no checked in version. So, in this case, the user can do two things to delete that folder. One, he can ask the person to check out in order to release the document or second, he can take ownership of that document.
So in rare cases, suppose a user takes the ownership of that document that is checked out by someone else.

Now, the user is able to see both documents.

Now, the user can discard check out or can check-in.

Now if the user wants to delete the folder he can successfully delete that folder.
Note: For security reasons, it is not acceptable that someone else deletes our file. This is only acceptable when folders have some garbage files that have no meaning at all.
So here is the final output of the problem.


Now the folder has been deleted. This is also applicable when we try to delete the folder using custom code (JSOM, CSOM, SSOM, REST API, PowerShell).
Thanks for reading.
Please comment for a healthy knowledgeable conversation.