@Harshavardhan
Try below PowerShell:
$Web = Get-SPWeb "site collection URL"
$List = $web.Lists["document library name"]
$Item = $List.GetItembyID("document ID")
$Author = New-Object Microsoft.SharePoint.SPFieldUserValue($web, $Item["Author"])
$files=$List.RootFolder.files
for($i = 0; $i -lt $files.Count){
$file=$files[$i]
$f = $web.GetFolder($list.RootFolder.ServerRelativeUrl + "/" + $Author.user.displayname)
if ($f.Exists -eq $false)
{
$folder = $list.Items.Add($list.RootFolder.ServerRelativeUrl, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, $Author.user.displayname)
$folder.Update();
}
$file.MoveTo($folder.Url + "/" + $file.name)
}
Results:
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.