I'm trying to find two files called:
bitbucket_20181013.bak
bitbucket_20181013-237823-23.tar
I'm trying to find these files using the date extension "20181013" and I want to rename it to "{todaysDate}_bitbucket_backup.{ext}"
So far I have the following:
$date = [DateTime]::Nw.ToString("yyyyMMdd")
$file = "*$date*"
$name = "$($date)_Bitbucket_Backup"
Get-ChildItem -Path Microsoft.PowerShell.Core\FileSystem::\\KERGRINFS4\Seagate\Bitbucket_Backups\backups |
Where-Object { $_.Name -like $file } |
%{ Rename-Item -LiteralPath $_.FullName -NewName "$name + $_.extension" }
But it doesn't work, it returns: "20181014_Bitbucket_Backup + bitbucket_20181014.bak.extension" instead of "20181014_Bitbucket_Backup.bak"