title: How to rename large number of files using Powershell and a CSV
body: <p>Ultimately, I need a solid PowerShell script that will take a folder with several hundred video files, import the existing file names into the program, lookup the new file name in a CSV, and rename it.  The old filename is simply (ie. File1.mp4, File2.mp4, etc.)  I would like to appended a date to the front of the file in the format of (YYYY-MM-DD).</p>
  
  <p>For testing, I created a folder on my desktop with (10) text files, each with a unique file name.</p>
  
  <p>My CSV file appears as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/XSTgA.jpg" rel="nofollow noreferrer">Image of CSV</a></p>
  
  <p>The "newfilename" column, was created by using the Concatenate command in Excel. </p>
  
  <pre><code>`(=CONCATENATE(TEXT(A2, "yyyy-mm-dd")," ", B2)`
  </code></pre>
  
  <p>As much as I would just like PowerShell to handle everything, I feel using Excel for most of this might be the best way.</p>
  
  <p>In my testing, everything was in one folder.  However, at work, I will have video files on one drive, and the script will have to be in a folder on my desktop.  Because I am in a corporate network, I need a special batch file to run my scripts, which is nothing new.  I just modify the script name, and away it goes!</p>
  
  <p>So what commands do I need to do in order to have the script separate from the video files AND the CSV file?</p>
  
  <p>Here is the code that I have so far.  Everything works when it's in one folder.</p>
  
  <pre><code>PS C:\Users\ceran\Desktop\Rename Project&gt; Import-Csv -Path .\MyFileList.csv | ForEach-Object {
  &gt;&gt; $Src = Join-Path -Path $TargetDir -ChildPath $_.filename
  &gt;&gt; $Dst = Join-Path -Path $TargetDir -ChildPath $_.newfilename
  &gt;&gt; Rename-Item -Path $Src -NewName $Dst
  &gt;&gt; } 
  </code></pre>
  
  <p>Thanks in advance for the help!</p>
  
  <p>Chris</p>