home bbs files messages ]

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 68,813 of 68,980   
   JJ to Tom Del Rosso   
   Re: Is it a file or a folder...in a netw   
   01 Aug 24 23:06:44   
   
   From: jj4public@outlook.com   
      
   On Tue, 30 Jul 2024 19:46:07 -0400, Tom Del Rosso wrote:   
   > JJ wrote:   
   >>> On Mon, 29 Jul 2024 18:57:26 -0400, Tom Del Rosso wrote:   
   >>>> if exist "%file%\" (set type=Folder) else (set type=File)   
   >>>>   
   >>>> That works for a local file, but if %file% points to a network share   
   >>>> then it always says Folder.   
   >>>>   
   >>>> Are you seeing that too?   
   >>>>   
   >>>> This is for win7 (not this newsreader machine).   
   >>   
   >> @echo off   
   >> setlocal   
   >> set attr=   
   >> for %%A in ("%file%") do set attr=%%~aA   
   >> if "%attr%" neq "" (   
   >>  echo Not found.   
   >>  goto :eof   
   >> )   
   >> if "%attr:d=%" == "%attr%" (   
   >>  echo It's a file.   
   >> ) else (   
   >>  echo It's a folder.   
   >> )   
   >   
   > That's great. Thanks.   
   > But isn't the logic inverted in the first IF?   
   > If it doesn't exist then %attr% would be an empty string, I think.   
      
   You're right. It should be the opposite. I need more coffee...   
      
   --- 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