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

Olaf,

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