title: Renaming a copied file by adding '-copy-' followed by a number
body: <p>I am copying names using javascript, and a name should not duplicate. Then I am adding a counter with <code>-copy-</code>. For example, if the name is <code>joy</code>, then the result of the copy should be <code>joy-copy-1</code>. If I copy <code>joy</code> again, the resulting name should be <code>joy-copy-2</code>.</p>
  
  <p>I am using a <code>counter</code> but it is not correct. Because <code>counter</code> is always increasing, it is not depending on <code>name</code> value.</p>
  
  <p><strong>SAMPLE CODE:</strong> </p>
  
  <pre><code> var counter = 1;
   var index = _.find(documents, function (o) {
     console.log("---------------&gt;", counter++);                    
     o.name = o.name + '-copy-' + counter;
     return o._id.$oid == CompareValue;
   }); 
  </code></pre>
  
  <p>I am retrieving <code>name</code> from a JSON file and adding the <code>counter</code> number. But it is not correct.</p>
  
  <p><strong>Expected output</strong><br>
  <strong>For Example</strong></p>
  
  <blockquote>
    <p><strong><em>Name is joy;</em></strong><br>
    <strong>After Copy</strong><br>
    joy-copy-1<br><br>
    <strong>Again copy joy</strong><br>
    joy-copy-2<br><br>
    <strong>Again copy joy</strong><br>
    joy-copy-3<br><br>
    <strong>If I copy joy-copy-3 then,</strong><br>
    joy-copy-3-copy-1<br><br>
    <strong>Again copy joy-copy-3</strong><br>
    joy-copy-3-copy-2<br><br>
    <a href="https://i.stack.imgur.com/pZe8E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pZe8E.png" alt="enter image description here"></a></p>
  </blockquote>