Forum Discussion
VidRocksKay
Aug 31, 2022Copper Contributor
Rename folders based on a column in a CSV file using PowerSehll
Hi Everyone, I'm a beginner to PowerShell. I have a scenario where I need to rename a large amount of folders (see below) in to a new name based on a column value in CSV. Current folders na...
- Aug 31, 2022
You can use this code to fix it
$csv=Import-Csv -Path C:\boot\Book3.csv Foreach ($Name in $csv){ try { $Filter=$Name.SamAccount.Replace('.','') +'*' Get-ChildItem -Directory -Path C:\boot -Filter $Filter | Rename-Item -NewName $name.SamAccount } catch { $_.Exception.Message } }replace the Path and you are good to go
farismalaeb
Aug 31, 2022Iron Contributor
as I can see, the folder name is UserName with no dot with a number
and the names in the CVS are usernames with a dot in the middle
are all the names following the same naming convention.?