Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Hi Joe,


On Thu, 10 Apr 2014 22:18:15 -0500
Joe B <paperbag76@gmail.com> wrote:

Paul, your answers are extremely helpful and polite.
Glad I can help!

I know you won't see this for awhile.  That's ok.  I can't believe
you're still up anyways, seeing as I think you're in South Africa
from your e-mail address.
Yeah, I'm a bit of a night owl, although last night was probably later
than normal for me.

I think I've sort of underestimated my explanation of my knowledge of
computer science to you.  I do understand for-loops very well.  What
I am asking has more to do with paths and filesystems I think.
Ok, sure, sorry, you had said you weren't much of a programmer and I
knew you were missing something so I figured I'd cover it completely.

When I say, "Where does the .bat file for-loop know where to find
the .htm files to iterate over?", I don't mean in the actual for-loop
code.  I understand, the for loop code looks at the "conditional"
part of the for-loop.  What I mean is, where is this list of files in
the computer's filesystem?
If you are working at the command line, most commands work only in the
current directory. For example, the "dir" command only lists files in
the current directory. It lists subdirectories, but not the files in
them. Shell globbing (translating the *.htm to a list of files ending
in .htm) also works only in the current directory. The shell interprets
the wildcard pattern, and looks for all files in the current directory
that match that pattern, and gives that list of files to the command
instead of the wildcard pattern you typed.

This is the same behaviour on *nix. On *nix you can use "pwd" to get
the "present working directory", on Windows it seems that just typing
"cd" gives you the current directory, but it should also be part of the
prompt. I'm sure you know that you can use the "cd" command to "change
directory", and that's on both windows and *nix.

So when typing the script out at the command line instead of running it
from a batch file, it will always work in whatever directory you're
currently in. If you put the script in a batch file, it still only
works in the current directory. If you run the batch file from the
command line, the current directory is whichever directory you are in
when you run the script, not the directory in which the script is. So,
for example, if the script is in "c:\utils" but you are in "c:\docs",
you will need to either add "c:\utils" to the path, or run the script as
"c:\utils\script.bat". In either case, that just tells the shell where
to find the script, it doesn't change the current directory, so the
script resides in "c:\utils", but is run in and acts on the files in
"c:\docs".

If you run the script by double clicking it from windows explorer,
there is still a current directory that the script runs in, it's just
behind the scenes, and windows sets the current directory of the
executing script to the directory it is saved in. So if the script is in
"c:\utils" and you double click it from within windows explorer, it
will run in "c:\utils".

This can be changed, of course. You need to create a shortcut to the
script, and then right click the shortcut to set properties. You will
see that the "target" field refers to the script itself, but there is
also a "Start in" field, which by default will be the same directory as
the script is in. If you change that, it will change the
current directory that the script executes in.

Alternatively, you can put a "cd" command in the script itself to
change to the desired directory before the rest of the instructions.

In sum: Does this mean that my .bat file would have to go into the
same windows directory as my input .htm files, in order to know which
".htm" files it should use to create the glob?
Yes, exactly.

And thus, generally speaking, does this mean that .bat files must
always go into the same directory as the files that they take as
input?
Yes, unless you put "cd" commands in the batch file, or use a shortcut
to change the working directory.

I'm really sorry if this is basic stupid questions.  I learned some
high level languages, but never DOS.
Heh, I started in the days before windows, so DOS was the only way to
do things.

The fundamentals are the same on DOS and *nix, although the *nix command
line has a lot more power. I'd recommend reading up a bit on this.
Windows GUIs are a fancy way of doing essentially the same stuff, and
often this sort of thing is going on under the hood, so understanding
it sometimes comes in handy.


Hope you're all squared away now.

Paul

-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.