renaming files

Hi guys,

I have to rename over 2000 files.

I get the files by using:

$List = Get-ChildItem -Filter 2015

Then i only want the first 8 characters and i do:

$List = ForEach-Object {$a.Substring(0,13)}

The i add some text

$b = $a | Foreach-Object{ $_ + 'bw’ }
$c = $b | Foreach-Object{ $
+ ‘.pdf’ }

But i only receive the last file in the c$ could somebody help me to change all the filenames put it in a string and then rename the files on fileserver

You should start with learning the basics of Powershell. Here are some good sources: Beginner Sites and Tutorials
Your task could be accomplished like this:

Get-ChildItem -Path C:\sample* -Filter 2015 |
ForEach-Object -Process {
$newName = $($.BaseName.substring(0,8)) + 'bw’ + $($.Extension)
Rename-Item -Path $
.FullName -NewName $newName
Of course you should change the starting path to your needs


Thank you very much, i rather new to powershell that’s correct. Will follow your advice. thanks!