Dear all,
Probably a silly question for many of you. Currently I manage three different computers in three different places. I want something on the top of my *do files which will identify the computer based on the computer name `c(hostname)' and then set path to certain directory. Currently I write the paths on the top of each *.do file and write a comment to identify which path is for which computer (say, home-pc, work-psy, work-bio etc) . The problem is if I am to work with more number of computers (say 7 or 8, I am going to ), under current practice, I will have to eyeball and identify the name of the computer in the dofile-comments to find out the computer in order to set the directory path. I am wondering of writing a loop which will do the work for me based on the computer name. I tried with the following code and no change is made to the path. I might be doing something silly and there might be more efficient way of achieving this. Have a look please my codes below:
The middle one is a Windows (OS-Windows 7, 64bit) computer and the two others (first and the third) are (Mac-OSX, version 10.10.5). Any suggestion is appreciated.
All the best
Probably a silly question for many of you. Currently I manage three different computers in three different places. I want something on the top of my *do files which will identify the computer based on the computer name `c(hostname)' and then set path to certain directory. Currently I write the paths on the top of each *.do file and write a comment to identify which path is for which computer (say, home-pc, work-psy, work-bio etc) . The problem is if I am to work with more number of computers (say 7 or 8, I am going to ), under current practice, I will have to eyeball and identify the name of the computer in the dofile-comments to find out the computer in order to set the directory path. I am wondering of writing a loop which will do the work for me based on the computer name. I tried with the following code and no change is made to the path. I might be doing something silly and there might be more efficient way of achieving this. Have a look please my codes below:
Code:
pwd // Current directory /Users/Rom // Change path based on the computer name: if "`c(hostname)'" == "Roms-MBP" { cd "/Users/Rom/Desktop/MY_FILES/1.PROFESSIONAL/UNI/EB/REE" } if "`c(hostname)'" == "CZC6058HTY" { cd "C:/Users/mm597/UNI/EB/REE" } if "`c(hostname)'" == "bio-bs20895" { cd "/Users/mm597/UNI/EB/REE" } pwd /Users/Rom //No change is made to the directory path
The middle one is a Windows (OS-Windows 7, 64bit) computer and the two others (first and the third) are (Mac-OSX, version 10.10.5). Any suggestion is appreciated.
All the best
Comment