running many files through the same command
Hi again,
thanks for the reply. First of all, I found out that the app will let me =
do a simple
pre602.exe /d:5 xxx.wp .602
and it will automatically put in the xxx, so it is not a problem =
anymore.
But let's say the app didn't let me do that. I tried what you said, and =
I was able to come up with the following procedure.
C:\ set fname.wp=3Dxxx.wp
C:\ pre602.exe /d:5 xxx.wp %fname%.602
This works well from the command line. However, if I write a .bat file =
like this (so that I can use it for the "convert" action in explorer)
set fname.wp=3D%1
pre602.exe /d:5 %1 %fname%.602
it doesn't work, since Windows puts in the full path (i.e. C:\xxx.wp) =
rather than just the file name (i.e. xxx.wp) for %1. Is there any way to =
refer to the file name without the full path?
Thanks much,
Ivan
"jt3" wrote in message =
...
Off the top of my head, I would do that using environmental =
strings with
the SET command--you can define some environmental variable, say FNAME =
with
the SET command, and set it to the filename, sans extension, then, =
when you
run the batfile you have %FNAME%.wp in the reference variable and the =
batch
processor will replace %FNAME% with the string in the SET command, say =
SET
FNAME=3Dxxx, to use your example. That way, you only need execute the =
SET
command to load the env. var. before you execute your .bat file.
The so-called dummy arguments referred to as %1, %2, etc., in the =
batch
file are simply replaced by the arguments, in numerical order, given =
on the
batch file command line, as for a batch file copyme.bat
COPYME first.dat second.exe third.com (space separated =
vars.)
would perform operations referring in the batch file to 'first.dat' as =
%1,
'second.exe' as %2, etc. But they're always used as parameters, not
strings.
Hope this is what you need,
Joe
"Ivan B=FAtora" wrote in message
...
Thanks for the e-mail. Actually, the program does accept wildcards (I =
don't
know why I thought it didn't.) So indeed, that solves my first =
question - it
is quite easy to do a mass conversion.
What about the second question, though? Is there any way to refer to =
the
part of a file before its extension? You mentioned %1, %2, etc. How =
are %2
or %3 different from %1?
=20
=20
"jt3" wrote in message
...
Ivan,
It's been a long time since I did any batch programming, and on =
6.22,
as
well, and 7 is no doubt somewhat different, but the first order =
approach
(easiest) depends upon whether or not your program pre602.exe will =
accept
wildcard characters, *, or ?, or not. If so, it is as easy as =
pre602 *.wp
*.602, conceivably. If you want a list, use the redirections symbol =
to
have a function such as dir put it into an output file. Remember =
that if
you execute a batch file within a batch file, the command processor
doesn't
return to the calling batch file unless you use the CALL command to =
load
another copy of the command processor. Reference any dummy =
parameters as
%1--%9, SHIFT can be used to access more than nine dummy args. FOR =
loops
are available if necessary:
FOR %%x IN(1, 2, 3, 4) DO something %%x
where x is a value taken from the list (1, 2, 3, 4), etc., and is a
parameter in executing 'something' where 'something' can be almost
anything
except another FOR (no FOR nesting).
IF statements are pretty standard though limited to:
IF string1=3D=3Dstring2 command (can also be EXIST, or NOT =
EXIST,
etc., as in =
a file
referenced)
This can also test for an ERRORLEVEL (var) condition if the program =
gives
an
ERRORLEVEL output.
Statement labels begin with a colon, and GOTO references the name =
without
the colon. For output, there's REM, ECHO (ON or OFF), and PAUSE, =
which
stops execution, displaying "Strike a key when ready.." until the =
key is
struck, allowing resumption of processing. I believe that there are =
more,
some of which came in about 6.22 and later which I never used and =
don't
recall, but this might be enough to do what you want?
Pardon me if I have misinterpreted your question and regaled you =
with
the obvious.
Joe
"Ivan B=FAtora" wrote in message
...
Hi everyone,
not sure if the subject of this thread is a good way to describe =
what I
want
to do, but here it is. Basically I wish to convert several (many) =
files
from
WordPerfect format to T602 format. For this, I have a small utility
"pre602.exe" which functions in this way:
PRE602.EXE [parameters] inputfile outputfile
In my case, let's say I wish to convert a file called "text.wp", I =
would
do:
pre602 /d:5 text.wp text.602
Question 1
Imagine I have twenty files I want to convert, and I don't want to =
do each
one individually. Is there any way to do this using a batch file? If =
I put
all those files in one folder, is there any way how to generate a =
list of
those files, and then run this list through the pre602.exe command
automatically?
Question 2
I want to define a custom action for .wp files which would do the
conversion
to .602. I was able to do something like this:
pre602.exe /d:5 %1 new.602
However, I am not able to figure out a way to refer to the part of =
the
filename before the file extension, and thus I had to make the =
output file
something fixed, which I subsequently have to rename. I know "%1" =
refers
to
the file that the action is taken on. If the file is, say, "xxx.wp", =
is
there any way to refer just to "xxx"?
Thanks for your input.
Ivan
=20
|