Avatar of bibi92
bibi92
Flag for France asked on

add at the end of the log the number of files treat, remaining and errors

Hello,


How can I add at the end of the log the number of files treat, remaining and errors, please ?

ForEach-Object {
		$Directory = $_.Group
		$PrefixList | ForEach-Object {
			$Prefix = $_
			$Directory | Where-Object {$_.Name -like $Prefix} | Sort-Object -Property Name | Select-Object -First 1 | ForEach-Object {
				$NewName = $_.BaseName.SubString(1) -replace '_\d{8}_\d{6}\Z'
				Try {
					Rename-Item -Path $_.FullName -NewName $NewName -ErrorAction Stop -WhatIf
					$Result = 'OK'
				} Catch {
					$Result = $_.Exception.Message
				}
				$_ | Select-Object 'DirectoryName', 'Name', @{n='NewName'; e={$NewName}}, @{n='Result'; e={$Result}}
			}
		}
	} | Format-Table -AutoSize | Out-String -Width 1024 | Out-File E:\log.txt -Encoding Default -ErrorVariable ERR1 -Append

Open in new window

     
Thanks

Regards
Powershell

Avatar of undefined
Last Comment
bibi92

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
bibi92

ASKER
Thanks regards
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes