Solved

Batch file help

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!!
17 answers Last reply Best Answer
More about batch file help
  1. 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?
  2. 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
  3. 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?
  4. 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
  5. 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?
  6. 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.
  7. 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?
  8. Yes. Extension is numeric.New files only downloaded upon request.
  9. 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.
  10. 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.
  11. 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?
  12. 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 "
  13. 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!
  14. It worked!! Thank you so much for your time and efforts.!
  15. Best answer
    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. :)
  16. Best answer selected by jrjetta.
  17. 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.
Ask a new question

Read More

File Name Windows XP