# Save Function not quite right

**URL:** <https://discourse.processing.org/t/save-function-not-quite-right/15027>\
**Category:** Coding Questions\
**Created:** [October 29, 2019, 5:25pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027 "2019-10-29T17:25:48Z")\
**Posts on this page:** 6\
**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, 5:25pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/1 "2019-10-29T17:25:48Z")

</div>

Hi!  
i’m trying to have a save function that allows you to name the file and choose where you would like your save to go.

So far with the code I have, its allows you to save and make/choose a folder but then places it onto the desktop with the name of the folder added onto the files name.

Have a look with the code below, any help would be great.Thanks!

```auto
void setup(){
  size(1080,720);
  background(255);
}
  
void draw(){
  ellipse(100,100,100,100);
  strokeWeight (50);
}
  
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");
  }
}

```

---

<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, 5:29pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/2 "2019-10-29T17:29:10Z")

</div>

Try println dir2

What do you get?

---

<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, 5:32pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/3 "2019-10-29T17:32:19Z")

</div>

Where about do you mean?

like:

```auto
   String dir2 = selection.getPath();
    println(dir2+"Painting#.jpg");

```

---

<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, 5:33pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/4 "2019-10-29T17:33:03Z")

</div>

Yes for example- either dir2 alone or with add

---

<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, 5:34pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/5 "2019-10-29T17:34:06Z")

</div>

Maybe you have to insert

```auto

+ "//" +

```

before filename ?

---

<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, 5:36pm UTC](https://discourse.processing.org/t/save-function-not-quite-right/15027/6 "2019-10-29T17:36:02Z")

</div>

```auto
+ "//" +

```

That worked!  
Thank you so much
