I have 5 variables and I have 3 files.
$NumOne = Read-Host 'Enter four digit numone'
$NumTwo = Read-Host = 'Enter two digit numtwo'
$sdataJRN= $NumOne + $NumTwo + "00" + ".jrn"
$sdataJNM = $NumOne + $NumTwo + "00" + ".jnm"
$sdataTXN = $NumOne + $NumTwo + "00" + ".txn"
Right now the three files are 06540200.jnm and jrn and txn respectively.
I want to rename each of these files. Instead of being 00 at the end I want 99. 06540299 jrn jnm txn
I am doing this with the following lines:
Rename-Item $sdataJRN -NewName $NumOne,$NumTwo,"99",".jrn"
Rename-Item $sdataJNM -NewName $NumOne,$NumTwo,"99",".jnm"
Rename-Item $sdataTXN -NewName $NumOne,$NumTwo,"99",".txn"
This returns an error.
Rename-Item : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'NewName'. Specified method is not supported. At line:1 char:34 + Rename-Item $sdataJRN[0] -NewName <<<< $storeNum,$regNum,"99",".jrn" + CategoryInfo : InvalidArgument: (:) [Rename-Item], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.RenameItemCommand