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,725 of 42,547    |
|    Todd Vargo to gwhite@ti.com    |
|    Re: FOR /F and delims=\ string processin    |
|    14 Aug 13 17:40:06    |
   
   From: tlvargo@sbcglobal.netz   
      
   On 8/14/2013 2:39 PM, gwhite@ti.com wrote:   
      
   > To me, it seems that the parsing part of the FOR "engine" only sees it as a   
   string. That means it does not know if "d" is a file or a folder, so one can   
   simply extract a folder name by using file syntax. It would be the same if   
   the folder or file    
   name was "d.x". (It has an extension.)   
   >   
   >   
   > The part I don't quite get in this is the "\." suffix. Once you got me on   
   the right track, I tried all these "in (...)" combos and got the same results   
   for all:   
   >   
   > for /f "delims=" %%G in ("%cd%\.") do set "folder=%%~nxG"   
   > echo.   
   > echo %%cd%%\. %folder%   
   > echo.   
   > for /f "delims=" %%G in ("%cd%.") do set "folder=%%~nxG"   
   > echo.   
   > echo %%cd%%. %folder%   
   > echo.   
   > for /f "delims=" %%G in ("%cd%") do set "folder=%%~nxG"   
   > echo.   
   >   
   > The syntax for all of the above work whether the directory is "d" or "d.x"   
   >   
   > For me trying to understand the command line, I ask what does the "\."   
   suffix do?   
   >   
   > I also noticed I can eliminate "delims=" and get the same results for that   
   path. But it breaks if there are spaces (like C:\a\b\c c\d), so I am I right   
   that "delims=" sets the delimiter to "nothing?" (Meaning, there are no   
   delimiters, take the whole    
   string.)   
      
   The \. does not do anything in this case and can be omitted. In a   
   general sense, it refers to the current folder which is already provided   
   by the %cd% variable. And you are correct about the purpose for "delims=".   
      
   Type FOR/? at the prompt for further information.   
      
   --   
   Todd Vargo   
   (Post questions to group only. Remove "z" to email personal messages)   
      
   --- 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