Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
Is it possible to pass values from one batch file to another? I have an exe that outputs a batch file with current date information. I need to pass the date values (year, month, day) into another batch file. The 2nd batch outputs a text file, and in the text file's name I must include today's date. How can i accomplish this?
I want to pass YEAR, MON, DOM from this file:
@echo off
Set YEAR=2004
Set PYEAR=2003
Set YR=104
Set PYR=103
Set MON=12
Set DOM=02
Set DOW=Thu
Set HOUR=10
Set MIN=48
Set YDOM=01
Set YMON=12
Set YYEAR=2004
Set YYR=104into this file:
ENVTIME > Time.bat
RUN time.bat
ftp -n -s:geodeftp_get.scr
java -cp "G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\GeodeFixSummary.class"; GeodeFixSummary GEODE.out fix.drkw.%YEAR%%MON%%DOM%.1.txt
G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\files
ftp -n -s:geodeftp_send.scr
@echo Complete!
Explorer G:\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script
quitHelp!

Your post looks quite confused, the second batch does not follow common script rules (RUN Time.bat?). So clarify your needs as the problem can be solved, but in 2K/XP there are constraints on passing variables from one batch to another as there is no permanent common environment set up.

sorry, let me clarify a bit...
The following batch file retrieves a file via ftp, sends it to a java class for processing, outputting a text document. The text is then saved locally. The batch runs perfectly - however, despite my best efforst, I cannot figure out a way to dynamically append today's date to the file and open it in notepad (or other default text editor). I have tried dating and naming the file in the java class, which worked nicely, but am unable to make the batch script open it, since it is a dynamic reference.
here is the .bat file:
Test.bat
1 ftp -n -s:geodeftp_get.scr
2 java -cp "G:\Portfolio\Portfolio Trading\Clients\Geode Capital\EOD_FIX_SUmmary_Script\GeodeFixSummary.class"; GeodeFixSummary GEODE.out
3 ftp -n -s:geodeftp_send.scr
4 start notepad xxxx.txt
5 @echo Complete!
6 quitLine 1 retrieves a file from an ftp
Line 2 sends the log file to the java class for processing
Line 3 saves the output file to the local directory
Line 4 would open the output file in notepad for the user to display and work with - this is where the problem isAs far as i know, there is no way to pass a parameter (such as a string containing the date)from the java class to the batch. The other way would be to retrieve and format the date in the batch script, which i have no idea how to do.
I did find a utility, envtime.exe that retrieves current date info and stores them in another .bat file:
Time.bat
@echo off
Set YEAR=2004
Set PYEAR=2003
Set YR=104
Set PYR=103
Set MON=12
Set DOM=02
Set DOW=Thu
Set HOUR=10
Set MIN=48
Set YDOM=01
Set YMON=12
Set YYEAR=2004
Set YYR=104
Is it possible to run envtime.exe, have it output Time.bat and pass the date parameters (YEAR, MON, DMON) into test.bat, so I can name the file dynamically AND open with the 'start notepadd xxxxxx.txt' line?

why not make a batch file that runs envtime, time.bat, test.bat and notepad?
something like this:@echo off
envtime.exe > c:\temp\time.bat
call c:\temp\time.bat
call c:\temp\test.bat
start notepad c:\temp\test.txt
exitIf you do not specify folder for time.bat, system may try to run time command. Or, just change the name of the time.bat file to something like timedata.bat

I'm as confused as anyone.
But the simple answer is to send a parameter from bat1 to bat2:
call bat2 parameter
For multiple bats and exes, the environment varibles are the simplest way. Any bat or conforming exe / com has access the the varibles which you set.
M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |