Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,576 of 42,547    |
|    nathanwilson41@gmail.com to All    |
|    Re: Dynamic Setting of variable based on    |
|    19 Nov 12 02:01:31    |
   
   All thanks for help so far but have hot a snag.   
      
   The code above is working BUT   
      
   The second entry the file name is not being used by the called process.   
      
   It is using the value nx1 and not the value for the variable eg folderName   
      
   As you can see from below it seems to be losing the variable.   
      
   C:\Test>rem Get Files from Remote Location   
      
      
      
   C:\Test>Set QM=D2MSBK61   
      
      
      
   C:\Test>for / %A in (C:\Test\*) do (   
      
   for %B in ("%A\*") do call :process "%A" "%B"   
      
    Set folderName=%~nxA   
      
    Set fileName=%~nxB   
      
    echo: UTILITY   
      
    echo: %~nxB   
      
   )   
      
      
      
   C:\Test>(   
      
   for %B in ("C:\Test\A\*") do call :process "C:\Test\A" "%B"   
      
    Set folderName=A   
      
    Set fileName=%~nxB   
      
    echo: UTILITY   
      
    echo: %~nxB   
      
   )   
      
      
      
   C:\Test>call :process "C:\Test\A" "C:\Test\A\W.bar"   
      
      
      
   C:\Test>Set folderName=nx1   
      
      
      
   C:\Test>Set fileName=nx2   
      
      
      
   C:\Test>echo Processing nx2 in nx1   
      
   Processing nx2 in nx1   
      
      
      
   C:\Test>echo Full Paths are "C:\Test\A\W.bar" and "C:\Test\A"   
      
   Full Paths are "C:\Test\A\W.bar" and "C:\Test\A"   
      
      
      
   C:\Test>call PROCESS.cmd D2MSBK61 nx1 nx2   
      
   --- 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