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,987 of 68,980    |
|    Herbert Kleebauer to icaro    |
|    Re: split a variable that contains a pat    |
|    01 Jan 23 10:56:43    |
   
   From: klee@unibwm.de   
      
   On 01.01.2023 01:25, icaro wrote:   
   > Hi all,   
   > I have a batch file with a variable containing a random path, eg   
   > C:\some\thing\not\so\useful   
   > and I need to have an output splitted in this way (the first line must   
   > contail the drive and the first directory)   
   >   
   > C:\some   
   > C:\some\thing   
   > C:\some\thing\not   
   > C:\some\thing\not\so   
   > C:\some\thing\not\so\useful   
      
   @echo off   
   set p=C:\some\thing\not\so\useful\   
   for /f "tokens=1,2* delims=\" %%i in ('echo %p%') do set p=%%k&set q=%%i\%%j   
      
   :loop   
   echo %q%   
   if [%p%]==[] goto :eof   
   for /f "tokens=1* delims=\" %%i in ('echo %p%') do set p=%%j&set q=%q%\%%i   
   goto :loop   
      
   --- 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