Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Running do files from other folders?


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: Running do files from other folders?
Date   Mon, 10 Nov 2008 13:11:59 -0500

Hi, Martin,

    if you type <<di  `"`c(pwd)'\.."'>> then it will -display- the
parent's directory name.
    if you type <<dir `"`c(pwd)'\.."'>> then it will display the
parent's directory files list.

   in both cases do not type << and >>

In Windows there is no error message if you are already in the root
dir, the parent of the root dir will be the rootdir itself. Don't know
if it's good or bad.

Best regards,
    Sergiy Radyakin


On Sat, Nov 8, 2008 at 8:43 AM, Martin Weiss <[email protected]> wrote:
> Sergiy,
>
> your suggested command
>
> dir `"`c(pwd)'\.."'
>
> gives me the parent directory name, but not the filelist of the parent
> directory. Is that what you wanted to happen?
>
> HTH
> Martin
> _______________________
> ----- Original Message ----- From: "Sergiy Radyakin"
> <[email protected]>
> To: <[email protected]>
> Sent: Saturday, November 08, 2008 12:04 AM
> Subject: Re: st: Running do files from other folders?
>
>
>> Yes, Robert, you can do that, given that the .do file itself does not
>> expect to be run from a particular directory. As in a frequent case,
>> when a do file (stored with an accompanying dataset) starts with -use
>> blahblah.dta-. Then if you run it from a different directory (with the
>> full path preceding the file name), the do file will run, but it will
>> not find the data and will not function properly.
>>
>> 1) you may refer to data by absolute paths in the do file
>> 2) you can -chdir- to the directory where the data file is located and
>> then execute it with -do- or -run-
>> 3) other options are available in case #1 and #2 do not help.
>>
>> Don't forget to use quotes if the path contains spaces.
>>
>> c(pwd) will tell you the current directory if you need to address it
>> in your program. E.g.
>> dir `"`c(pwd)'\.."'
>> will display the filelist of the parent directory of the current
>> directory.
>>
>>
>> Regards, Sergiy Radyakin
>>
>>
>> On Thu, Nov 6, 2008 at 5:04 PM, Ploutz-Snyder, Robert (JSC-SK)[USRA]
>> <[email protected]> wrote:
>>>
>>> Colleagues;
>>>
>>> Newbie question:
>>>
>>> Is it possible to run do files that is located in a different directory
>>> from which you are working?
>>>
>>> For example, if I am working in a folder called
>>> D:\StataData\ThisProject, and I want to call a do file from a different
>>> folder, like say D:\StataData\ThatProject, is this possible?
>>>
>>> I have similar needs for calling do files in main directories from
>>> within sub-directories.  I'd like to save all of my various do files in
>>> a primary folder (D:\StatData ) but then have the ability to call them
>>> from any other sub-directory..or possibly from folders on different
>>> drives or otherwise NOT within the parent directory.
>>>
>>> Seems like you should be able to do something like:
>>>
>>> Run D:\BlahBlahDirectory\NiftyDoFile Arg1 Arg2 Arg3
>>>
>>>
>>> Ideas?
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/statalist/faq
>>> *   http://www.ats.ucla.edu/stat/stata/
>>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index