# Error with this save function

**URL:** <https://discourse.processing.org/t/error-with-this-save-function/15026>\
**Category:** Coding Questions\
**Created:** [October 29, 2019, 4:33pm UTC](https://discourse.processing.org/t/error-with-this-save-function/15026 "2019-10-29T16:33:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozman](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@ozman](https://discourse.processing.org/u/ozman)\
**Post date:** [October 29, 2019, 4:33pm UTC](https://discourse.processing.org/t/error-with-this-save-function/15026/1 "2019-10-29T16:33:12Z")

</div>

Hi!  
Im trying to have a save function that allows you to select the folder it goes into.

```auto
void keyPressed()
{
  if(key == 'r'){
    {
    setup();
  }
if(key ==' ')
{
  selectFolder("select a folder to process","folderSelected");
}
  }
 void folderSelected (File selection)
{
  if(selection == null)
  {
    return;
  }
  else
  {
    String dir2 = selection.getPath()+ "\\";
    save(dir2+"Painting###.jpg");
  }
  }
}

```

The error i’m getting at the moment is:

> unexpected token: void

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 29, 2019, 4:47pm UTC](https://discourse.processing.org/t/error-with-this-save-function/15026/2 "2019-10-29T16:47:03Z")

</div>

you had a duplicate

```auto
  {
 {

```

at ‘r’ and one too much } at the very end

```auto

void keyPressed()
{
  if (key == 'r') 
  {
    setup();
  }
  if (key ==' ')
  {
    selectFolder("select a folder to process", "folderSelected");
  }
}//func 

void folderSelected (File selection)
{
  if (selection == null)
  {
    return;
  } else
  {
    String dir2 = selection.getPath()+ "\\";
    save(dir2+"Painting###.jpg");
  }
}//func

```

---

<div class="post-metadata">

**Author:** ![ozman](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@ozman](https://discourse.processing.org/u/ozman)\
**Post date:** [October 29, 2019, 4:50pm UTC](https://discourse.processing.org/t/error-with-this-save-function/15026/3 "2019-10-29T16:50:38Z")

</div>

Thank you!  
sloppy error by me D:
