Good Morning,
I have hundreds of files in subfolders with a root directory of - "C:\Layout\PDF" The files are 7 digits with "_Email". (ie 9991234_Email.pdf) How can I get a PowerShell Script to change the file names within all of the subdirectories to be 7 digits with "_Proof" Instead? (ie 9991234_Proof.pdf)
Any assistance would be greatly appreciated!
Thank you!
$inPath = 'C:\Layout\PDF\'
$outPathRoot = 'C:\Layout\PDF\'
Get-ChildItem -Recurse -LiteralPath $inPath -Filter *_Email.pdf | ForEach-Object {
$targetDir = New-Item -Type Directory -Force ($outPathRoot)
$EmailFiles = Get-ChildItem | Where-Object {$_.Name -like "_Email*"}
ForEach($File in $EmailFiles)
{
$newname = ([String]$File).Replace("_Email","_Proof")
Rename-item -Path $File $newname
}