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 40,723 of 42,547   
   gwhite@ti.com to All   
   FOR /F and delims=\ string processing   
   12 Aug 13 17:56:51   
   
   Hi,   
      
   In a batch file, I want to assign a variable as a string with the current   
   directory stripped of the parent directories.   
      
   Say I am "in" (batch file doesn't know where it is run from):   
      
   C:\a\b\c\d   
      
   I want to set a variable to d.   
      
   If I do   
      
   set x=%cd%   
   echo %x%   
      
   Then the command screen shows:   
      
   C:\a\b\c\d   
      
      
   I tried various ways of FOR /F with delims=\ to strip off all but "d", but I   
   can't figure it out.   
      
   I'm a hack when it comes to batch files.  Does anyone know how to do this?   
      
   (I am trying to use it on Win7 command line at the moment.)   
      
   Thanks!   
      
   --- 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