Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,534 of 68,980    |
|    JJ to Mark Ise    |
|    Re: for-loop cannot process braces    |
|    06 May 20 04:26:42    |
      From: jj4public@vfemail.net              On Tue, 5 May 2020 16:17:38 +0200, Mark Ise wrote:       >       > Could you give me a more concrete help? I have no idea how to do that?       >       > Usually I put the files by drag n drop to the batch. Therefore I have       > made a test with three files and a test-batch: echo %*       >       > The output is:       >       > echo "F:\z2\Test1 ().txt" F:\z2\Test2().txt F:\z2\Test3.txt       > "F:\z2\Test1 ().txt" F:\z2\Test2().txt F:\z2\Test3.txt       >       > Is it possible to put always quotes arround every single parameter?       > I think it would be the more compatible way.              CMD already have the %1, %2, etc. variables for the batch parameters. If a       parameter is quoted, %~1, %~2, etc. will strip the enclosing quotes. e.g. if       the the batch commandline is like this:               mybat "F:\z2\Test1 ().txt" F:\z2\Test2().txt F:\z2\Test3.txt              %1 will be: "F:\z2\Test1 ().txt"       And %~1 will be: F:\z2\Test1 ().txt              With that in mind, you can use SHIFT to access the next batch parameter       using a fixed pseudo variable. e.g.               @echo off        setlocal        :ProcessParam        if "%~1" == "" goto :eof        set fn=%~1        echo %fn%        shift        goto ProcessParam              Or in a more structured way like this.               @echo off        setlocal        :CheckParam        if "%~1" == "" goto :eof        call :ProcessParam %1        shift        goto CheckParam               :ProcessParam        set fn=%~1        echo %fn%        goto :eof              To use FOR command for parsing the batch parameters, each batch parameter       must be quoted as needed. Otherwise it'll break FOR commmand's functionality       like what you're having problem with.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca