Q. How can I rename many files in a folder with specific requirements using PowerShell?
A. PowerShell has powerful string manipulation capabilities that can easily be used when renaming bulk files by saving all the target files to an array then performing the rename on each file in the array. In the example below I save all the files to a variable ($files) then for each file in the array its filename has c11 replaced with c12 within that filename.
$files = Get-ChildItem -Path C:\Temp
foreach ($file in $files)
{
$newFileName=$file.Name.Replace("c11","c12")
Rename-Item $file $newFileName
}
0 comments
Hide comments