title: Check if file exists locally in Adobe Extendscript
body: <p>I try to check for local files (.jpg) using a plain js loop. I get an error that, for example, file <code>5d3eb1905b243.jpg</code> does not exists, but actually it does.</p>
  
  <p>Also, I don't understand why the <code>else</code> statement ins't working and why <code>5d3eb1905b243.jpg</code> isn't replaced with <code>none.jpg</code>.</p>
  
  <p>Maybe the path is the problem?</p>
  
  <p>Here's the code:</p>
  
  <pre class="lang-js prettyprint-override"><code>if (obj[i].hasOwnProperty('sharedimage_id')) {
    var imgFile = new File(
      '/Users/student/Desktop/seminar_robobooks/archiv/img/' +
        obj[i].sharedimage_id +
        '.jpg',
    );
  
    if (imgFile.exists) {
      noStroke(imgFile);
      image(obj[i].sharedimage_id + '.jpg', 56.5, 70.793, 69, 42);
    } else {
      noStroke(imgFile);
      image('none.jpg', 56.5, 70.793, 69, 42);
    }
  }
  
  </code></pre>