Computing.Net > Forums > Disk Operating System > passing parameters to batch?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

passing parameters to batch?

Reply to Message Icon

Name: sajjadr21
Date: December 5, 2003 at 02:38:23 Pacific
OS: XP
CPU/Ram: 504 MB
Comment:

hi all,

I want to set the value of topdir dynamically in the following batch.
For example, I have a simple html file as following

<html><head><title></title></head>
<body>click here to continue</body></html>

when user click on the link in above html file, it fires the batch.bat. I want to select the path which is before batch.bat and set it as a top directory.

Is it possible to do that in dos?

Thanks,
Sajjad
----------------------batch.bat--------------
@echo off
set topdir=C:\kix\Enterprise0311141\Enterprise
set tempdir=C:\temp
set style=C:\tree.xsl
set look4file=xmlinterlinks.xml




Sponsored Link
Ads by Google

Response Number 1
Name: sajjadr21
Date: December 5, 2003 at 05:00:57 Pacific
Reply:

i have figured it out with a little issue

when i pass it to my batch file as following

c:\1xml>copyfile.bat "c:\1xml\test\test1"

it copies the file.

But if there is a string like "c:\1xml\test\test1 cont\cont" then it does not work

any suggestion?


0

Response Number 2
Name: sajjadr21
Date: December 5, 2003 at 06:07:12 Pacific
Reply:

i have resolved this issue as well but still i am having issue with white space created at the end!

any suggestion about stripping the white space?

here is the new batch

set topdir=%1

:beginloop
if "%1"=="" goto endloop
shift

set topdir=%topdir% %1
goto beginloop

:endloop

echo %topdir%


0

Response Number 3
Name: IVO
Date: December 5, 2003 at 06:38:19 Pacific
Reply:

If the target is just to catch into the variable ALL the command tail, use the following

Set topdir=%*

that disregards blanks before and after the last string typed but retains that interspersed ones. If all the typed input has to be stored into one variable, it is the straigthforward method.


0

Response Number 4
Name: sajjadr21
Date: December 5, 2003 at 06:48:52 Pacific
Reply:

cheers...i ve resolved the issue by looking at my typo

i will try IVO's method as well to test!


0

Response Number 5
Name: sajjadr21
Date: January 16, 2004 at 00:43:50 Pacific
Reply:

hi all,

here is the command
call construct_xml_doc "%topdir%\dirlist.txt" "%topdir%\dirlist.xml"

1) when i set the top directory without spaces, the command works fine. e.g
set topdir=c:\a\folder\to\process
2) when i set the top directory with spaces, it does not work at all e.g
set topdir=c:\a\folder\with spaces\to\process

any suggestions, why it is giving the error "system can not find the file spaces"

regards,
/s

*********construct_xml_doc*********************
@Echo Off

:: LST2XML.BAT Syntax: Lst2Xml File_In File_Out

Echo ^<?xml version="1.0" encoding="ISO-8859-1"?^>> %~f2

Echo ^<someURIs^>>> %~f2
For /F "tokens=*" %%A in (%~f1) Do Echo ^<file^>%%A\file.xml^</file^>>> %~f2
Echo ^</someURIs^>>> %~f2
**************************************************



0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: passing parameters to batch?

passing param to batch from HREF www.computing.net/answers/dos/passing-param-to-batch-from-href/14323.html

Passing parameters www.computing.net/answers/dos/passing-parameters/14546.html

Passing Variable to Batch www.computing.net/answers/dos/passing-variable-to-batch/9649.html