Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • whats the working directory of a nested .do file?

    I have a main script file called mainproject.do and within it is do call for another script called analysis1.do. This analysis1.do file is in a folder which also has data files that the analysis1.do uses. But now every time I run my main script file, its cant access the data files when the analysis1.do runs, and shows that the working directory is that of mainproject.do directory rather than analysis.do. How do I resolve this so that everytime a nested .do file is called, the working directory becomes of the nested .do file.

  • #2
    You only have one working directory at a time: The working directory has application-level scope. If you want to change the working directory, you can do that manually with the cd command. You can cd to the current directory at the first line of every do file you write. Just keep in mind that if you change the working directory in a nested do file, you might need to change it back in the calling do file.

    Edit: you could also call cd in the main do file just before you call the nested do file. I write my do files using the first pattern, but it's really just a stylistic choice.
    Last edited by Daniel Schaefer; 05 Aug 2023, 21:44.

    Comment

    Working...
    X