dos batch file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This may not be the right group, please redirect me if necessary.

I am trying to create a very simple batch file that looks in the root of the
current directory to see if a file with the extension "*.inp" exists in each
of the folders. If a folder contains this file type, I would like to call
another program with that file as input (shown below as jumper.inp, as I know
the real file name). Below is what I have so far:

path=c:\windows\system32;C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel

for /R %%X IN (*.inp) DO call ansys100 -b -p ane3 -i jumper.inp -o output.out


The above does find the file, but then when it executes the call command it
says it can't find the file. Do I need to change to that local directory to
excute the call, and if so what would be the syntax of doing that and
returning to the first directory to continue the loop? Is there another way
to accomplish what I am trying?

Thanks,

Jason
 
TxRaistlin said:
This may not be the right group, please redirect me if necessary.

I am trying to create a very simple batch file that looks in the root of the
current directory to see if a file with the extension "*.inp" exists in each
of the folders. If a folder contains this file type, I would like to call
another program with that file as input (shown below as jumper.inp, as I know
the real file name). Below is what I have so far:

path=c:\windows\system32;C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel

for /R %%X IN (*.inp) DO call ansys100 -b -p ane3 -i jumper.inp -o output.out


The above does find the file, but then when it executes the call command it
says it can't find the file. Do I need to change to that local directory to
excute the call, and if so what would be the syntax of doing that and
returning to the first directory to continue the loop? Is there another way
to accomplish what I am trying?

Thanks,

Jason

Path: You should add to the path, not replace it as it appears you are
doing.

I can't tell for sure, but it doesn't look like you have a path to the
file you actually want; it seems to go beyond it.

alt.msdos.batch.nt is a pretty helpful site and I've used it before.
Lots of good folks there; give them a try.

Pop`
 
TxRaistlin said:
This may not be the right group, please redirect me if necessary.

I am trying to create a very simple batch file that looks in the root of the
current directory to see if a file with the extension "*.inp" exists in each
of the folders. If a folder contains this file type, I would like to call
another program with that file as input (shown below as jumper.inp, as I know
the real file name). Below is what I have so far:

path=c:\windows\system32;C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel

for /R %%X IN (*.inp) DO call ansys100 -b -p ane3 -i jumper.inp -o output.out


The above does find the file, but then when it executes the call command it
says it can't find the file. Do I need to change to that local directory to
excute the call, and if so what would be the syntax of doing that and
returning to the first directory to continue the loop? Is there another way
to accomplish what I am trying?

Thanks,

Jason

Try this:
@echo off
for %%x in (*.inp) do call ansys100 -b -p ane3 -i %%x -o output.out

The word "call" is only required if "ansys" is a batch file. If it
is a .exe file then you should remove "call".

By the way, DOS is an operating system. There is no DOS under
WinXP, only a Command Prompt.
 
Thansk for the link to an alternate forum, will check there as well. I
purposefully am trying to call the jumper.inp file, without the path info,
b/c when i tried the -i %%X approach, it found the file but put the entire
path in as an input, and the ansys program didn't recognize it.

Onre last question, is there a simple way to strip the path information off
of a variable?
 
There is a way to strip the path information but the syntax
is not straightforward. However, in your case there does
not seem to be any path information - you are already in
the folder where jumper.inp resides.
 
Finally figured it out thanks in part to replies here and at another forum:

for /R %%X in (*.inp) do (
cd %%~pX
ansys100 -b -p ane3 -i %%~nxX -o output.out
cd..
)


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top