Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Help writing bat file

Feb 18, 2008 11:04AM PST

I am newbie to batch files. Any help would be appreciated.
I want to execute a dtsx package first and when complete execute an ant file.

First, I want to check if any files (.txt) exists in a folder.
IF exists *.txt in D:\folder
if yes:
(C:\SQL\ProjectName\bin - do I haveto set the path first?)
execute dtexec /f mypackage.dtsx
then:
(D:\MyTools\bin)
execute ant -buildfile D:\project\conf\file.xml

If no files exists and folder is empty : quit


Hope this makes sense,
Jill

Discussion is locked

- Collapse -
Pick your choice from ...
Feb 19, 2008 4:07AM PST
- Collapse -
vauge suggestions....
Feb 19, 2008 4:53AM PST

Thanks for the warm welcome Kees!
Thanks for the suggestion to actually perform a search on Google, mind blowing! I have already searched around and have not been able to find a particular good tutorial.
Hence the post.
If you have a particular tutorial that you have used and would like to recommend that would be cool.

- Collapse -
Re: tutorial
Feb 19, 2008 9:11PM PST

I learned it from the DOS 5.0 manual.

What's your exact problem? I mean, what particular command don't you grasp? And what part works?
I see the following elements:
- if to see if files exist
- cd to jump to the right folder
- running a program

Tell more on where you get stuck.

Kees

- Collapse -
This is what I got..
Feb 22, 2008 8:32AM PST

This is what I got so far and this works.
Is there anyway I can verify that the second process does not starts until the first has completed?

@echo
If exist C:\testFolder\testfile.txt (
echo file exists
cd "C:\Documents\JillH\Desktop\EmbeddedSQL\DB_Project_INT\bin"
dtexec /f loadRArecords.dtsx
REM(The next process should not start until the first one has completed)
cd "C:\Client\Tools\bin"
ant -buildfile C:\Client\Tools\config\demo_1.xml
) else (
echo file does not exists
EXIT
)

Thanks,

- Collapse -
Re: batchfile
Feb 22, 2008 11:57PM PST

Try start with the /wait switch for the first program. Help start in the command window will give some info. Like
start /wait dtexec ...

Hope this helps.


Kees