Statalist


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

st: Re: two questions about the shell command behavior -- Windows XP


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: two questions about the shell command behavior -- Windows XP
Date   Mon, 8 Dec 2008 22:56:49 +0100

Re backslash see Nick`s http://www.stata-journal.com/article.html?article=pr0042

HTH
Martin
_______________________
----- Original Message ----- From: "Gabi Huiber" <ghuiber@gmail.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Monday, December 08, 2008 10:51 PM
Subject: st: two questions about the shell command behavior -- Windows XP


Hello everybody,

I need to make room on a disk and I thought I'd do this on an ongoing
basis from within a larger Stata process that runs every day. So I
need to move files around. I thought that this prototype would get me
started:

clear
set more off

local root      "c:/work/my root directory/"
local to_path   "to_here\"
local from_path "from_here\"
local move_this "example_list.txt"

cd "`root'"

!move `from_path'`move_this' `to_path'`move_this'
dir "`to_path'"
dir "`from_path'"

!move `from_path'example_list.txt `to_path'example_list.txt
dir "`to_path'"
dir "`from_path'"

I have two questions about the shell command:

1. The shell modifier (shell or !) seems to pass along the local
macros with the immediate folder names -- `from_path' and `to_path' --
but it does not do the same with the local macro that holds the file
name. It would be nice if it did, because local macros that hold file
names would make it a lot easier to loop across multiple file name
variants. Does anybody know what explains this selective treatment of
local macros?

2. The shell modifier does not allow me to enclose file path or file
name macros in quotes in order to accommodate spaces. In this case I
cd'd into the `root' path and the very last folders of interest had no
spaces, but I won't always be so lucky. Does anybody know of a
workaround?

3. This is more an idle puzzle than a real issue, though it might grow
into one. When I started using forward slashes in Stata, I thought I
could do so because Windows didn't care either way. But it does. The
XP command prompt does not recognize forward slashes. So it's very
nice of Stata to make that problem go away, especially if you have
folder names whose first character, when paired with a backslash,
could be mistaken for a special character. I guess, though, that Stata
can only go so far in offering this convenience. You have to
relinquish it when you invoke the shell, it seems. Too bad, but not
critical.

But issues (1) and (2) are nuisances, and they are strange. Inside
Stata you can string along as many macros as you want, so (1) should
not be an problem; and you can use quotes to declare file paths with
spaces in them both inside Stata and at the Windows command prompt, so
(2) shouldn't be one either.

Thank you,

Gabi
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index