How to export an image to a directory higher than the file that creates it

Since I keep the lettering .tex

for the paper in the same git repository as all the software needed to generate the required numbers, I have the following directory structure:

+- code
|   +- script.jl
+- figures
|   +- figure.eps
+- ...

      

If it does script.jl

export figure.eps

, is it possible to directly export it to a folder figures

? Or the highest level I can export to the script itself (i.e. code

)?

Sorry if this is a stupid question; As you can tell from the context in which the question arises, I am more of a researcher than a programmer and searching for the keywords that come to mind has brought nothing useful.

Thanks for any suggestions!

+3


source to share


1 answer


You can export your data to any location on your computer that you have access to. As Dan Goetz said, joinpath

is your friend when specifying a directory, so you don't have to worry about using different OS.

It's also important to consider where you are calling the script from. If I am in path/to/code

and execute julia script.jl

then I can use joinpath("..","figures","figure.eps")

just fine because the path will be calculated from your current working directory.



However, if you want to specify a path relative to the location of script.jl (so that you can call the script from anywhere), you can use a macro @__DIR__

that returns the absolute path of the directory that contains the file in which the macro was called.

joinpath(@__DIR__,"..","figures","figures.eps")

+4


source







All Articles