368d6fafea
Code backup
27 lines
613 B
PowerShell
27 lines
613 B
PowerShell
$Logfile = "F:\Code\VSC\PowerShell\Script\005 - Rename File by csv\logs.txt"
|
|
|
|
$Elements = Import-Csv -Path "C:\Users\cbo\Desktop\FZ Task\username2.csv"
|
|
$i = 1
|
|
|
|
|
|
foreach ($Element in $Elements) {
|
|
|
|
$FilePath = "C:\Users\cbo\Desktop\FZ Task\Voutcher to send\"
|
|
$OldfileName = $i.ToString("000") + ".pdf"
|
|
|
|
$Target =$FilePath + $OldfileName
|
|
$FileName = $Element.Surname + " " + $Element.Name + ".pdf"
|
|
|
|
Rename-Item -Path $Target -NewName $FileName
|
|
|
|
LogWrite($FilePath+$FileName)
|
|
|
|
$i++
|
|
}
|
|
|
|
Function LogWrite
|
|
{
|
|
Param ([string]$logstring)
|
|
|
|
Add-content $Logfile -value $logstring
|
|
} |