Thursday 14 April 2011

Renaming files using PowerShell and a CSV

During a migration of users from an outside organisation into ours, we had to bring across all their exchange data using exmerge.

The problem was, all their exported PST's were named incorrectly.

So, a quick CSV was knocked up with two columns.
Column 1 = Path and current file name
Column 2 = New file name

Add a header at the top of the CSV to give something like this:

Path,NewAlias
F:\Export\fredb.pst,fred.bloggs.pst
F:\Export\DSaster.pst,derdrie.saster.pst

Then use the following PowerShell line:
import-csv c:\PSTImport.csv | foreach {rename-item -path $_.path -newname $_.newalias}
Job done, one nicely renamed folder of PST files ready to exmerge (shame we're still on Exchange 2003!)

No comments:

Post a Comment