Announcement

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

  • How to avoid changing directory every time?

    I am using two devices, every time that I want to open the do file that I developed on the other device, I need to change the directory. Using Stata with Dropbox can be problematic for example in terms of synchronizing. Is there any recommendation on how I can avoid changing the cd every time?

  • #2
    Perhaps you can make use of c(hostname) to automate the process with a few additional lines at the top of your do-file.
    Code:
    . display "`c(hostname)'"
    MacBook-WL
    
    . if "`c(hostname)'"=="MacBook-WL" local cdto "/Users/lisowskiw/Downloads"
    
    . if "`c(hostname)'"=="iMac-WL" local cdto "/Users/lisowskiw/Research"
    
    . cd "`cdto'"
    /Users/lisowskiw/Downloads
    
    .
    For more information about accessing the values of Stata system parameters and settings, see the output of the help creturn command.

    Comment


    • #3
      That is cool. I usually use the following less cool a low tech solution:

      Code:
      cd "/Users/lisowskiw/Downloads"
      *cd "/Users/lisowskiw/Research"
      All I need to do when opening a project is uncomment the appropriate command.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment

      Working...
      X