Hi @frob ,
You could follow the code below to rename each location. The FolderURL and FileURL below can be changed to folder or subfolder paths.
$SiteURL = "https://abc.sharepoint.com/sites/MeredithTest"
$FolderURL= "lib1/a/11"
$FolderNewName ="aa"
$FileURL= "lib1/a/aa/Document3.docx"
$NewFileName ="wenjian.docx"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Rename the Folder
Rename-PnPFolder -Folder $FolderURL -TargetFolderName $FolderNewName
#Rename the File
Rename-PnPFile -SiteRelativeUrl $FileURL -TargetFileName $NewFileName -Force
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.