I'm trying to insert today's date in file name which i'm coping from one location to another location.
Here is the copy script (Working),
$RemotePath = "E:\Test\AB"
$LocalPath = "E:\Test\CD"
$Max_days = "-1"
$Curr_date = get-date
Foreach($file in (Get-ChildItem $RemotePath))
{
if($file.LastWriteTime -gt ($Curr_date).adddays($Max_days))
{
Copy-Item -Path $file.fullname -Destination $LocalPath
#Move-Item -Path $file.fullname -Destination $LocalPath
}
ELSE
{
"not copying $file"
}
}
I need to add today's date in YYYYMMDD format to all files which i'm copying from $RemotePath to $LocalPath
Example, 1_20210715.txt
Could anyone please help me on this.