title: SSIS script to remove date from file name
body: <p>I need to create a SSIS script to remove the date from file name. for example file name is: TestFile_122413.CSV  I need to rename it to TestFile.CSV. I don't know how to keep file extension and how to deal with the date changes on file. I receive this file every day. Here is my code:</p>
  
  <p>`public void Main()
          // TODO: Add your code here</p>
  
  <pre><code>        const string DIRECTORY_PATH = @"E:\ScriptsTest";
  
          //const string FILE_NAME_TEMPLATE = "SSS_PROF_010113.CSV";
          const string FILE_NAME_TEMPLATE = "*.CSV";
  
  
          if (Directory.Exists(DIRECTORY_PATH))
          {
              string[] filePathList = Directory.GetFiles(DIRECTORY_PATH);
  
              foreach (string filePath in filePathList)
              {
                  if (File.Exists(filePath))
                  {
                      File.Move(filePath, filePath.Replace(FILE_NAME_TEMPLATE, FILE_NAME_TEMPLATE.Substring(0,8)));
  
                  }
              }
          }
  
  
      }`
  </code></pre>