Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to dictate the location of files

Status
Not open for further replies.

saqib11

Programmer
Jun 3, 2010
8
GB
I have control code (wrapper) which i use to run other excutables in a certain order. I have the seprate executables in folders, but when these executables are run the output files are created in the main folder where the control code is located. i want the output files to go into the folders associated with their executable, in order to avoid confusion cos there are hundreds of output files.

how do i control the location of the output files?

regards

saqib
 
also, if the files are already created, should i try move them to the new location, is this method easier or should i try to create them in the right folder in the first place?

i dont have the code to the executables

saqib
 
How does the executable know what your main folder is if the executable isn't yours?

It can only create files in the same folder or in prescribed directories thatmust exist before hand, I suppose.

If the executable is yours, just change it in fortran

OPEN(UNIT=1,FILE='./MyOutputDirectory/myoutputfile.dat',STATUS='REPLACE')

If the executable is not yours, you'll have to move them after creating them, I'd do that with some script in UNIX or some batch file if you're working in DOS/Windows, not with fortran.

 
GerritGroot,

The executable was given to me, it is a black box of which the ode i dont have. when run, it produces some out put files. i have folder A containing my code, which calls to run this executable. the executabl is within folder B and folder B is in folder A. the thing runs, but the out put files are created in folder A not within folder B where the executable is located.

i have contemplated looking further than fortran to re arrange the location of the files, but this is undesirable

please advise

regards

saqib
 
Hm, that's strange, so you executable knows (or the OS knows) that you're running it from another directory.

I understand that you're running like:
Code:
CALL SYSTEM('./B/MyBlackBoxExecutable.exe')
, right?

What you could try is simply placing the OS there
Code:
CALL SYSTEM('runmyblackboxexe.bat')
In which you do in your batch file the necessary stuff.

Code:
cd ./B
START /W MyBlackBoxExecutable.exe
cd ..

I hope it would create every file in directory B then
 
yes thats right i have:

CALL system ('B\blackbox.exe')

but i've never created a batch file, what is the procedure, do i write the code in fortran then?

i dont know what it means when you write:

cd ./B
START /W MyBlackBoxExecutable.exe
cd ..

place the OS where?

please clarify, it would be a great help.

saqib
 
Look at "Command-line reference A-Z" in the windows help
 
A batch file is a simple script (from the ice age) that you run under the commandline prompt (inside cmd.exe which can be found in your windows directory)

The batch file itself is nothing more than a text file saved with the extension .bat in stead of .txt

In the text file you give your commands to DOS as if you were typing them yourself.

For further explanations on te DOS commands themselves you should look outside this forum and google on "DOS batch". If you want to know anything about the commands I used, type "[command] /?" at the prompt.

It looks like this:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top