cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
austinspencer
Level II

How to get the path to the current project file?

If I have a script within a project (or perhaps a reference to the project in a script outside of the project), how to do I get the file path to where the project is saved on disk?  I'm interested in doing this with JSL, not interactively.

7 REPLIES 7
austinspencer
Level II

Re: How to get the path to the current project file?

Based on the silence, I'm guessing that this may not be (easily) possible?

Craige_Hales
Super User

Re: How to get the path to the current project file?

I struggled with this too. Even if it was possible, it would not work for what I wanted to do because the files in a project are unpacked on demand, not when the project is first opened. My use case was needing a filepath for a resource in the project...that would go to an external program. I wound up using loadtextfile(proj file name)/savetextfile($temp/name) and sending the temp file name.

 

Using a Project for a Project - Audio.jsl passes a file to powershell to play.

 

What are you trying to do?

Craige
austinspencer
Level II

Re: How to get the path to the current project file?


What are you trying to do?


That's a good question, and probably one I should have answered in the original question.  When working on a project, sometimes it would be helpful to be able to quickly copy the path to the project to either open the containing folder to view other associated files or to store the link in my notes or send to a coworker.  This is a relatively common and useful feature found in many code editors and office suite software.  Of course you can just browse to the file through other means, but it's a common enough task for me that it's handy to have a quick method that doesn't require me to mentally parse my file organization structure each time.  Thanks for your time!

Craige_Hales
Super User

Re: How to get the path to the current project file?

@aaron_andersen , @julian  - He's right; I've resorted to using file->SaveAs to discover the path in the past. The home window's recent file list is better, offering both copy path and open containing window. Maybe those could also be exposed on data table, script, and project windows as well. The system popup off the title bar might be an alternative to the file menu.

I think projects may be a special case from JSL; data tables and scripts can already get their path.

 

Craige
austinspencer
Level II

Re: How to get the path to the current project file?


@Craige_Hales wrote:

@aaron_andersen, @julian  - He's right; I've resorted to using file->SaveAs to discover the path in the past.

Yeah, I've used that on occasion as well.  From what I recall, it won't work if you've not saved the project file since opening it though.

The home window's recent file list is better, offering both copy path and open containing window.

Ah, that's at least a decent workaround.  Thanks.

Maybe those could also be exposed on data table, script, and project windows as well. The system popup off the title bar might be an alternative to the file menu.

I think projects may be a special case from JSL; data tables and scripts can already get their path.

 


Having this function in some menu would be great.  If it were available through JSL as well, that would be a plus.

Re: How to get the path to the current project file?

I do not find a function specific to a JMP project. There is no path variable for projects either. You are free to save a project anywhere you like. It is a kind of JMP file, so when you open or save a project, JMP will start with the last directory. You can get this information using the Get Default Directory() function.

dir.JPG

austinspencer
Level II

Re: How to get the path to the current project file?

Thanks for looking into this.  I've had luck using Get Default Directory() in bare scripts, but when a script is saved in a project, it just returns the path inside the project file rather than where the project is stored:

Get Default Directory() = "jmpprj://contents/";