text: function renameFiles(namesStart) {
    const names = namesStart.slice();
    for (let i = 1; i < names.length; i++) {
      for (let j = i - 1; j >= 0; j--) {
        if (names[j] === names[i]) {
          if (
            names[j][names[j].length - 1] === ')'
            && names[i][names[i].length - 1] === ')'
          ) {
            // names[i] += '(1)';
            names[i] = names[i].concat('(1)');
          } else {
            for (let innerJ = i - 1; innerJ >= 0; innerJ--) {
              if (names[innerJ] === names[i]) {
                if (
                  names[j][names[j].length - 1] !== ')'
                  && names[i][names[i].length - 1] !== ')'
                ) {
                  names[i] = names[i].concat('(1)');
                } else {
                  names[i] = names[i].replace(
                    '('.concat(names[i][names[i].length - 2], ')'),
                    '('.concat(
                      ((parseInt(names[i][names[i].length - 2], 10) + 1)).toString(), ')',
                    ),
                  );
                }
                innerJ = i - 1;
              }
            }
          }
          break;
        }
      }
    }
    return names;
  }
  
  module.exports = renameFiles;
  