Fun With Windows PowerShell

I haven’t posted anything geeky or techy lately, so I felt the need to do so.

Recently at work, I was given a DVD containing a data dump of closed loans. And when I say “data dump”, I mean almost 7,000 individual image files that used to be full loan packages, all stored in a spiderweb of folders that seemed to make NO SENSE WHATSOEVER.

“Christy, we need to be able to sort these out so we can review each loan.”

::Christy’s eyes cross::

Luckily, there was a csv file on the DVD that included paths to where each individual page of each loan was located.

Here’s how I did it.

# Where is the csv file?
$text = "\\domain\root\Imaging\Folder\key.csv"
# Okay, import the csv file data.
$loans = Import-Csv -Path $text
# Assign the loan number, the path and a unique filename to 
# usable variables.
	foreach($strLoan in $loans)
		{
		$loanNum = $strLoan.LoanNum
		$location = $strLoan.Path
		$name = $strLoan.Filename
		$destination = "\\domain\root\Imaging\Folder\Loans\"
# Test if a folder exists for that loan number already.
# If not, create one.
		if (!(Test-Path $destination$loanNum))
		{
			New-Item $destination$loanNum -type directory
		}
# Copy all the guts associated with that loan number
# to the correct folder.
		Copy-Item $location $destination$loanNum\$name
		}
Clear-Host
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Want to share?
This entry was posted in Techy Stuff and tagged , , , , . Bookmark the permalink.

2 Responses to Fun With Windows PowerShell

  1. Josh Atwell says:

    Very cool! Well done!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Hawk says:

    What a plesaure to find someone who thinks through the issues

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published.