# P5.js - sketch trying to load images from previous sketches

**URL:** <https://discourse.processing.org/t/p5-js-sketch-trying-to-load-images-from-previous-sketches/16830>\
**Category:** Coding Questions\
**Created:** [January 3, 2020, 12:24pm UTC](https://discourse.processing.org/t/p5-js-sketch-trying-to-load-images-from-previous-sketches/16830 "2020-01-03T12:24:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebekah\_tkd](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@rebekah\_tkd](https://discourse.processing.org/u/rebekah_tkd)\
**Post date:** [January 3, 2020, 12:24pm UTC](https://discourse.processing.org/t/p5-js-sketch-trying-to-load-images-from-previous-sketches/16830/1 "2020-01-03T12:24:23Z")

</div>

I’m trying to call an array of images. My sketch keeps trying to load images which are not added within the sketch. These files were loaded in previous sketches, therefore this somehow overrides the images I am attempted to load. The images in the previous sketch were named ‘0.png’ ‘1.png’ etc etc. I have now named my images ‘A.png’, ‘B.png’ etc

Here is my code:

function preload() {  
for (var index = 0; index \< totalImages; index++) {  
allImages[index] = loadImage(index + “.png”);  
}

my error:

It looks like there was a problem loading your image. Try checking if the file path [[https://editor.p5js.org/bekah\_mbrown/sketches/osyQni0v1/7.png](https://editor.p5js.org/bekah_mbrown/sketches/osyQni0v1/7.png)] is correct, hosting the image online, or running a local server.[[https://github.com/processing/p5.js/wiki/Local-server](https://github.com/processing/p5.js/wiki/Local-server)]

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [January 3, 2020, 5:26pm UTC](https://discourse.processing.org/t/p5-js-sketch-trying-to-load-images-from-previous-sketches/16830/2 "2020-01-03T17:26:31Z")

</div>

If you named your images ‘A.png’, ‘B.png’, etcetera, then using `index` (which is a number) to form the file’s name won’t work.

Or did I misunderstand you?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 4, 2020, 2:16am UTC](https://discourse.processing.org/t/p5-js-sketch-trying-to-load-images-from-previous-sketches/16830/3 "2020-01-04T02:16:05Z")

</div>

but could use

```auto
  for ( let i = 0; i < 5 ; i++ ) print( char(i+65) +'.png');

```

prints

```auto
A.png 
B.png 
C.png 
D.png 
E.png 

```
