Sign in with
Sign up | Sign in
Your question
Solved

Batch file help

Last response: in Windows XP
Share
October 27, 2010 3:29:34 PM

Hello,

I need to setup a batch file to run an executable - rjeassem. In the input field the file name will be changed each time it is downloaded. The output filed I would like to name attus and overwrite it each time the batch file is run. Any help setting this up would be much appreciated!!

More about : batch file

October 28, 2010 7:41:48 AM

jrjetta said:
I need to setup a batch file to run an executable - rjeassem.


Hello, can you explain a little bit more what you want to do?

You have an executable file called rjeassem.exe? What kind of parameters does this program need?

jrjetta said:
In the input field the file name will be changed each time it is downloaded.


What is being downloaded? What is the names that needs to be changed?

jrjetta said:

The output filed I would like to name attus and overwrite it each time the batch file is run.


Can you please explain this too? What is "attus"? And is there an output file or field?
m
0
l
October 28, 2010 7:17:19 PM

Thanks for your reply.
Did help on rjeassem.exe input_file output_file
Where input_file = your data file
output_file = where you want this program to write
input file example is 22209702.012 - extension would change each download.
Would like to make output named attus
m
0
l
Related resources
October 28, 2010 7:56:33 PM

jrjetta said:
Thanks for your reply.
Did help on rjeassem.exe input_file output_file
Where input_file = your data file
output_file = where you want this program to write
input file example is 22209702.012 - extension would change each download.
Would like to make output named attus


So a working line could look lite this?

> rjeassem.exe 22209702.01 attus

And no other parameters? And no file extension on the attus file?

This input file, where is it located? Is there other files in the same directories? Could anything be known of the file name, or will all the numbers both in file namn and extension be different all the time?

The old attus file should be saved?
m
0
l
October 29, 2010 4:23:07 PM

Thanks again for yor reply!
Yes the working line would look like that. the rjeassem is located in c:\gl\tfm\rje and I would like the output in the root of c: We don't need to save the old attus file as I still have a database file that is actually run thru this rjeassem program
m
0
l
October 29, 2010 4:37:16 PM


Hello, I would also need the information about the input file. From the previous post:

Quote:
This input file, where is it located? Is there other files in the same directories? Could anything be known of the file name, or will all the numbers both in file namn and extension be different all the time?
m
0
l
October 29, 2010 5:15:49 PM

Sorry, Input file is in the c:\datafile folder. Yes , there are other files in this folder. I believe just the extension will change. The file format is 22209702.xxx.
m
0
l
October 29, 2010 5:43:22 PM

jrjetta said:
Yes , there are other files in this folder. I believe just the extension will change. The file format is 22209702.xxx.


Is the filename always the same and the file extension is different?

How often does new files arrive to this folder?
m
0
l
October 29, 2010 6:28:06 PM

Yes. Extension is numeric.New files only downloaded upon request.
m
0
l
October 29, 2010 9:26:41 PM


Ok, so here is a prototype. It is not possible for me to actually test this, since I do not have of your inputfiles or the executable.


@ECHO OFF

SET exec=rjeassem.exe
SET execdir=C:\gl\tfm\rje
SET indir=C:\datafile
SET outdir=C:
SET outfile=attus
SET infile=22209702
SET tmp1=tmp-file1.txt
SET latestfile=

DIR "%indir%\%infile%.*" /b /on > %tmp1%
FOR /f %%a IN (%tmp1%) DO SET latestfile=%%a
IF EXIST "%outdir%\%outfile%" DEL "%outdir%\%outfile%"

"%execdir%\%exec%" "%indir%\%latestfile%" "%outdir%\%outfile%"

IF EXIST "%tmp1%" DEL "%tmp1%"


Please try it careful and do not run in production until you verified that it is working as expected.
m
0
l
November 1, 2010 7:11:29 PM

Hi,
Thanks for your time. I was able to test today. I get a file not found on the DIR line. I see a space between the c:\datafile and the 22209702. File not found. I will keep playing with it. Thanks again.
m
0
l
November 1, 2010 7:15:27 PM

jrjetta said:
Hi,
Thanks for your time. I was able to test today. I get a file not found on the DIR line. I see a space between the c:\datafile and the 22209702. File not found. I will keep playing with it. Thanks again.


Hello, there should be no spaces from the script. Did you copy the whole script above to a file and run?

Could you change the first line to: @ECHO ON

and run, and then paste all the output into here?
m
0
l
November 2, 2010 2:24:53 PM

C:\>SET exec=rjeassem.exe

C:\>SET execdir=C:\gl\tfm\rje

C:\>SET indir=C:\datafile

C:\>SET outdir=C:

C:\>SET outfile=attus

C:\>SET infile=22209702

C:\>SET tmp1=tmp-file1.txt

C:\>SET latestfile=

C:\>DIR "C:\datafile \22209702 .*" /b /on 1>tmp-file1.txt

C:\>FOR /F %a IN (tmp-file1.txt) DO SET latestfile=%a

C:\>IF EXIST "C: \attus " DEL "C: \attus "

C:\>"C:\gl\tfm\rje \rjeassem.exe " "C:\datafile \ " "C: \attus "
error: unable to read input file C:\datafile \
program terminated.

C:\>IF EXIST "tmp-file1.txt " DEL "tmp-file1.txt "
m
0
l
November 2, 2010 5:07:41 PM


Hello, the error is that the forum for some reason adds a space last to each line. This causes problems with the variables.

After copying the lines below to notepad, go to the end of each line and delete the space if there is one.

SET exec=rjeassem.exe
SET execdir=C:\gl\tfm\rje
SET indir=C:\datafile
SET outdir=C:
SET outfile=attus
SET infile=22209702
SET tmp1=tmp-file1.txt
SET latestfile=


Try again afterwards!
m
0
l
November 2, 2010 6:22:46 PM

It worked!! Thank you so much for your time and efforts.!
m
0
l

Best solution

November 2, 2010 8:31:49 PM

jrjetta said:
It worked!! Thank you so much for your time and efforts.!


Nice to hear! Best luck with the script.

Vote for "Best answer" in the thread if you would like to give points. :) 
Share
November 3, 2010 12:28:09 PM

Best answer selected by jrjetta.
m
0
l
November 3, 2010 12:47:59 PM

ricno said:
Nice to hear! Best luck with the script.

Vote for "Best answer" in the thread if you would like to give points. :) 

Would love to give points,. Can't figure out how.
m
0
l
!