original_string: protected function getFileName($strFile, $strFolder)
      {
          if (!file_exists(TL_ROOT . '/' . $strFolder . '/' . $strFile)) {
              return $strFile;
          }
  
          $offset = 1;
          $pathinfo = pathinfo($strFile);
          $name = $pathinfo['filename'];
  
          $arrAll = scan(TL_ROOT . '/' . $strFolder);
          $arrFiles = preg_grep('/^' . preg_quote($name, '/') . '.*\.' . preg_quote($pathinfo['extension'], '/') . '/', $arrAll);
  
          foreach ($arrFiles as $file) {
              if (preg_match('/__[0-9]+\.' . preg_quote($pathinfo['extension'], '/') . '$/', $file)) {
                  $file = str_replace('.' . $pathinfo['extension'], '', $file);
                  $intValue = intval(substr($file, (strrpos($file, '_') + 1)));
  
                  $offset = max($offset, $intValue);
              }
          }
  
          return str_replace($name, $name . '__' . ++$offset, $strFile);
      }
code: protected function getFileName($strFile, $strFolder)
      {
          if (!file_exists(TL_ROOT . '/' . $strFolder . '/' . $strFile)) {
              return $strFile;
          }
  
          $offset = 1;
          $pathinfo = pathinfo($strFile);
          $name = $pathinfo['filename'];
  
          $arrAll = scan(TL_ROOT . '/' . $strFolder);
          $arrFiles = preg_grep('/^' . preg_quote($name, '/') . '.*\.' . preg_quote($pathinfo['extension'], '/') . '/', $arrAll);
  
          foreach ($arrFiles as $file) {
              if (preg_match('/__[0-9]+\.' . preg_quote($pathinfo['extension'], '/') . '$/', $file)) {
                  $file = str_replace('.' . $pathinfo['extension'], '', $file);
                  $intValue = intval(substr($file, (strrpos($file, '_') + 1)));
  
                  $offset = max($offset, $intValue);
              }
          }
  
          return str_replace($name, $name . '__' . ++$offset, $strFile);
      }
code_tokens: protected function getFileName ( $ strFile , $ strFolder ) { if ( ! file_exists ( TL_ROOT . '/' . $ strFolder . '/' . $ strFile ) ) { return $ strFile ; } $ offset = 1 ; $ pathinfo = pathinfo ( $ strFile ) ; $ name = $ pathinfo [ 'filename' ] ; $ arrAll = scan ( TL_ROOT . '/' . $ strFolder ) ; $ arrFiles = preg_grep ( '/^' . preg_quote ( $ name , '/' ) . '.*\.' . preg_quote ( $ pathinfo [ 'extension' ] , '/' ) . '/' , $ arrAll ) ; foreach ( $ arrFiles as $ file ) { if ( preg_match ( '/__[0-9]+\.' . preg_quote ( $ pathinfo [ 'extension' ] , '/' ) . '$/' , $ file ) ) { $ file = str_replace ( '.' . $ pathinfo [ 'extension' ] , '' , $ file ) ; $ intValue = intval ( substr ( $ file , ( strrpos ( $ file , '_' ) + 1 ) ) ) ; $ offset = max ( $ offset , $ intValue ) ; } } return str_replace ( $ name , $ name . '__' . ++ $ offset , $ strFile ) ; }
docstring: Get the new file name if it already exists in the folder
  @param string
  @param string
  @return string
docstring_tokens: Get the new file name if it already exists in the folder