I tried to delete an empty folder from a document library using below mentioned workarounds but no success. Please anyone share some workarounds and help me to resolve this issue.
I am getting below mentioned error.
Error: - "The file is currently checked out or locked for editing by another user."
Workarounds and methods already used are mentioned below:
1. Manage files which have no Checkout versions - From Library settings, I used option "Manage files which have no Checkout versions" to find any checkout files which can cause error on deletion. But, I did not find any files there to take ownership and delete those files.
2. Delete From File explorer - Unable to see any files or folders from that document library not even other files and other folders.
3. Renaming folder - able to rename that empty folder and create sub-folders
4. Disable versioning settings - disable the versioning settings even not worked
5. Site content and structure- Unable to move or delete that empty folder.
6. PowerShell script to delete the folder by force discard checkout on files and folder then delete the folder.Below is the script used but no success for that document library folder but for other document library folder its working fine.
#[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Clear-Host;
$site = new-object Microsoft.SharePoint.SPSite("http://site-url")
$web = $site.openweb()
$list=$web.Lists["projects"]
foreach ($folder in $list.Folders)
{
if($folder.name.Contains("Delete"))
{ foreach($file in $Folder.Files)
{ try {
$file.CheckIn("CheckIn"); $file.UndoCheckOut; $file.Update();
UnlockFile $file
Write-Host "`t Unlocked File: " $file.Name
}
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Host $ErrorMessage
Write-Host $FailedItem
}
}
try
{
$folder.UndoCheckOut;$folder.Update();
Write-Host("DELETED FOLDER: " + $folder.name)
$list.Folders.DeleteItemById($folder.ID)
}
catch
{ $ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Host $ErrorMessage
Write-Host $FailedItem
}
}
}









