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,722 of 42,547   
   foxidrive to gwhite@ti.com   
   Re: FOR /F and delims=\ string processin   
   13 Aug 13 11:14:25   
   
   From: not@this.address.invalid   
      
   On 13/08/2013 10:56, gwhite@ti.com wrote:   
      
   > 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   
      
   Try this:   
      
   @echo off   
   for /f "delims=" %%a in ("%cd%\.") do set "folder=%%~nxa"   
      
      
   --   
   foxi   
      
   --- 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