home bbs files messages ]

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 41,532 of 42,547   
   Herbert Kleebauer to micky   
   Re: Is there a way to specify part of th   
   25 Feb 17 21:18:47   
   
   XPost: alt.msdos.batch.nt   
   From: klee@unibwm.de   
      
   On 25.02.2017 20:17, micky wrote:   
   >   
   > Is there a a symbolic variable that specifies part of the path?   
   > Specifically the last node (are they called nodes?).  That is, if it's   
   > C:\programs\housework\tuesday\ironing.exe  I want to get \tuesday\  with   
   > or without slashes.   
   >   
   > It's not necessarily 8 characters long, or any other predictable length,   
   > but I could use all the characters after the next-to-last slash, if   
   > there's a way to do that.   
      
      
   @echo off   
   set a=C:\programs\housework\tuesday\ironing.exe   
      
   for %%i in (%a%)    do set b=%%~dpi   
   for %%i in (%a%\..) do set c=%%~dpi   
   call set d=%%b:%c%=\%%   
      
   echo %a%   
   echo %b%   
   echo %c%   
   echo %d%   
      
   --- 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