windows - How to create a batch file that read parameters from another file

07
2014-07
  • sead

    Someone help me to create a batch file that reads three parameters from another file e.g. Config.conf in same directory?

    The Config file contains following information:

    --url="jdbc:oracle:thin:@192.168.0.91:1521:xe" --username=TestUser01 --password=passowrd01 
    

    I need to set three parameters %url%, %username%, %pwd%.

    This is my test.bat file @echo off setlocal for /f "usebackq tokens=1,2,3 delims=&" %%A in ("\98_Tests\config.conf") do ( set "%%A" set "%%B" set "%%C" ) echo %url% result is only 98_Tests–

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    command line - How to distinguish folders from files in a batch script? (Or how to copy & rename-timestamp them indiscriminately?)
  • fluxtendu

    I want to create a batch file to copy files or folders in a specified directory and append the date and time to their names.
    Here's my actual code:

    @echo off
    Set _bpath=T:\Backup\
    if [%1]==[] goto :eof
    :loop
    Set _file=%~n1%
    Set _ext=%~x1%
    For /f "tokens=1-3 delims=1234567890 " %%a in ("%time%") Do Set "delims=%%a%%b%%c"
    For /f "tokens=1-4 delims=%delims%" %%G in ("%time%") Do (
       Set _hh=%%G
       Set _min=%%H
       Set _ss=%%I
       Set _ms=%%J
    )
    copy %1 "%_bpath%%_file%(%date:/=-% %_hh%h%_min%m%_ss%s)%_ext%"
    shift
    if not [%1]==[] goto loop
    

    This one works for files only and I could adapt it easily for folders with xcopy /E %1 "%_bpath%%_file%(%date:/=-% %_hh%h%_min%m%_ss%s) but I would like to avoid dealing with two batch files.

    So how to copy/rename them indiscriminately (I have try with copy, xcopy and robocopy without success) or how to distinguish them to create two IF branch? (Using %~x1% is too unreliable...)


  • Related Answers
  • asdfg

    This might be useful to you, see this question