program define dropbox capture local dropbox : dir "/users/`c(username)'" dir "*Dropbox*" , respectcase if _rc==0 & `"`dropbox'"'~="" { local dropbox : subinstr local dropbox `"""' "" , all cd "/users/`c(username)'/`dropbox'/" exit } if _rc~=0 & "`c(os)'" == "Windows" { capture cd c:/ if _rc~=0 { nois di in red "Cannot find dropbox folder" exit } capture local dropbox : dir "/users/`c(username)'" dir "*Dropbox*" , respectcase if _rc==0 & `"`dropbox'"'~="" { local dropbox : subinstr local dropbox `"""' "" , all cd "/users/`c(username)'/`dropbox'/" exit } capture local dropbox : dir "/documents and settings/`c(username)'/my documents/" dir "*dropbox*" , if _rc==0 & `"`dropbox'"'~=""{ local dropbox : subinstr local dropbox `"""' "" , all cd "c:/documents and settings/`c(username)'/my documents/`dropbox'" exit } capture local dropbox : dir "/documents and settings/`c(username)'/documents/" dir "*dropbox*" , if _rc==0 & `"`dropbox'"'~=""{ local dropbox : subinstr local dropbox `"""' "" , all cd "c:/documents and settings/`c(username)'/documents/`dropbox'" exit } } if _rc~=0 & "`c(os)'" ~= "Windows" { nois di in red "Cannot find dropbox folder" exit } if _rc==0 & `"`dropbox'"'=="" { capture local dropbox : dir "/users/`c(username)'/Documents" dir "*Dropbox*" , respectcase if _rc==0 { local doc "Documents" } if `"`dropbox'"'=="" { capture local dropbox : dir "/users/`c(username)'/My Documents" dir "*Dropbox*" , respectcase if _rc==0 { local doc "My Documents" } } if `"`dropbox'"'~="" { local dropbox : subinstr local dropbox `"""' "" , all cd "/users/`c(username)'/`doc'/`dropbox'/" exit } if `"`dropbox'"'=="" & "`c(os)'" == "Windows" { local dropbox : dir "C:/" dir "*Dropbox*" , respectcase local dropbox : subinstr local dropbox `"""' "" , all cd "/`dropbox'" exit } } end