title: Using Powershell to recursively rename directories using a lookup file
body: <p>I need to rename a lot of directories and their sub directories.</p>
  
  <p>I have a csv file which contains the old directory names and the required new name.</p>
  
  <pre><code>1,blah,old_name1,new_name2,wibble
  2,foo,old_name2,new_name2,bar
  3,john,old_name3,new_name3,paul
  4,george,old_name4,new_name4,ringo
  </code></pre>
  
  <p>Note that some of the directory names are </p>
  
  <pre><code>old_name1-morestuffhere 
  </code></pre>
  
  <p>which need to be renamed to</p>
  
  <pre><code> new_name1-morestuffhere
  </code></pre>
  
  <p>I know broadly how I'd do this in bash: </p>
  
  <pre><code>mv -r `cat file.csv | awk -F, '{print $3* $4*}'`
  </code></pre>
  
  <p>..but I'm bound to and totally lost with powershell.</p>
  
  <p>EDIT: Here's what I've got so far. Is this close?:</p>
  
  <pre><code>cat .\file.csv | foreach { $oldname = $_.split(",")[2], $newname = $_.split(",")[3], move-item $oldname*, $newname*}
  </code></pre>