Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag 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
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bibi92

ASKER

Thanks regards