# sketchPath returns the wrong sketch path

**URL:** <https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215>\
**Category:** Processing\
**Created:** [September 26, 2019, 12:06pm UTC](https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215 "2019-09-26T12:06:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leo.nerd](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/leo.nerd/32/6101_2.png) [@leo.nerd](https://discourse.processing.org/u/leo.nerd)\
**Post date:** [September 26, 2019, 12:06pm UTC](https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215/1 "2019-09-26T12:06:08Z")

</div>

Hello. Windows user here. The sketchPath and dataPath methods seem to return the wrong sketch locations:

```auto
String sketchpath = sketchPath("");
println(sketchpath);

```

returns:  
`C:\Users\[my.username]\Documents\Processing\processing-3.5.3\` which is where Processing.exe is located but is NOT where the sketch is located.

Is this a known issue, is this normal behavior?

What are my options to dynamically refer to a subfolder of the data folder? I can’t use absolute paths because this code is shared among machines and should run regardless of the username and where the sketch is located.

Thank 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:** [September 26, 2019, 12:19pm UTC](https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215/2 "2019-09-26T12:19:29Z")

</div>

Win 10 / Processing 3.5.3

and test

```auto
println(sketchPath(""));
println(dataPath(""));

```

AFTER i saved the sketch  
works fine here.

please recheck File / Preferences / Sketchbook location:

* * *

also for usual coding not need it, i use like

```auto
String outfile = "data/mydata.csv";

```

and the sketch makes the data directory and saves the data correctly.  
please also experiment with this.

---

<div class="post-metadata">

**Author:** ![leo.nerd](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/leo.nerd/32/6101_2.png) [@leo.nerd](https://discourse.processing.org/u/leo.nerd)\
**Post date:** [September 27, 2019, 9:27am UTC](https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215/3 "2019-09-27T09:27:36Z")

</div>

Hey kll, thanks for you response. Again I’m looking for a way to read data from a subfolder inside the _data_ folder, not write any data out.

Additional fact that I can’t figure out but might be helpful: any new sketch will retrieve the correct sketchPath, but this particular one always outputs the wrong path (copied in my initial post), even when I copy it to another location first or when I recreate it from scratch from a blank sketch.

---

<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:** [September 27, 2019, 10:38am UTC](https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215/4 "2019-09-27T10:38:00Z")

</div>

-a-

```auto
String infile = "data/test/moonwalk.jpg";
PImage img = loadImage(infile);
println("load image from "+infile);

// load image from data/test/moonwalk.jpg

```

works as expected.

* * *

-b- so you have a bad sketch  
doing bad things,  
but you not post it ( or its MCVE ) here?  
but leave us guessing?

actually from your original post the idea could be that processing is damaged  
means delete systemdir

> c:\Users\ \< USER \> \AppData\Roaming\Processing\

and  
…/processing-3.5.3/…  
dir,  
download & unzip and restart.

but now??? better just delete the bad sketch.

* * *

again i look your first post:  
`C:\Users\[my.username]\Documents\Processing\processing-3.5.3\`  
is what?

and the sketchbook path is then?  
`C:\Users\[my.username]\Documents\Processing\`

that looks somehow bad, i would never install processing this way? but i can not say it is WRONG??

* * *

```auto
void setup() {
  size(300, 200);
  sysinfo();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System : " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") );
  println( "JAVA : " + System.getProperty("java.home") + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home : " + System.getProperty("user.home") );
  println( "user.dir : " + System.getProperty("user.dir") );
  println( "user.name : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath : " + dataPath("") );
  println( "dataFile : " + dataFile("") );
  println( "frameRate : actual "+nf(frameRate, 0, 1));
  println( "canvas : width "+width+" height "+height+" pix "+(width*height));
}

```
