4baa1093   
   Quinta-feira, 29 de Setembro de 2011 20:16:11 UTC+1, David S escreveu:   
   > On Sep 29, 3:26 am, "billious" wrote:   
   >    
   > > "David S" wrote in message   
   >    
   > >   
   >    
   > > news:5ae4be18-477d-44de-a419-44b617a72cf1@c1g2000yql.googlegroups.com...   
   >    
   > >   
   >    
   > >   
   >    
   > >   
   >    
   > >   
   >    
   > >   
   >    
   > > > I'm trying to delete an empty file in a specific directory.   
   >    
   > > > I want to scan the directory.   
   >    
   > > > If there is an empty file with the extension of zip, txt or jpg   
   >    
   > > > its deleted   
   >    
   > > > call to c++ app   
   >    
   > > > end   
   >    
   > > > if the are no empty files then   
   >    
   > > > end   
   >    
   > >   
   >    
   > > > I consider an empty file to be zero bytes   
   >    
   > > > This is what I have......I know its similiar to my other post, but   
   >    
   > > > different, The other is time this size.   
   >    
   > > > Any help is appreciated. Thank you.   
   >    
   > > > David   
   >    
   > >   
   >    
   > > > @echo off   
   >    
   > > > cd "C:\Users\DS\Downloads"   
   >    
   > > > setlocal   
   >    
   > > > for /f "delims=" %%a in ('dir *.jpg *.zip *.txt /a-d /b')   
   >    
   > > > if "%~z1" == "0" del %file%   
   >    
   > >   
   >    
   > > > CD C:\RIAA\Warning\debug\   
   >    
   > > > IF EXIST "Warning.exe" call Warning.exe ELSE echo "Does not exists"   
   >    
   > > > goto :EOF   
   >    
   > >   
   >    
   > > > I'm gettin incorrect syntax.   
   >    
   > >   
   >    
   > > Not surprising   
   >    
   > >   
   >    
   > > for /f "delims=" %%a in ('dir *.jpg *.zip *.txt /a-d /b') DO   
   >    
   > > if "%%~za" == "0" del "%%a"   
   >    
   > >   
   >    
   > > ( all as one line )   
   >    
   > >   
   >    
   > > 1/ Missing DO   
   >    
   > > 2/ %%~za to get the size of file %%a, not %~z1   
   >    
   > > 3/ "%%a" not %file% In all probability, FILE is not an assigned variable,   
   so   
   >    
   > > %file% will be replaced by NOTHING. Even if it did exist AND contained a   
   >    
   > > valid filename, you would be attempting to delete that file for each   
   >    
   > > 0-length file found. Quotes around %%a not necessary, but advisable to   
   cater   
   >    
   > > for spaces and other special characters in the filename %%a.   
   >    
   > >   
   >    
   > > And I'm not sure whether the size reported for a file that is in the   
   process   
   >    
   > > of being created is zero until it's closed by the generating program...-   
   Hide quoted text -   
   >    
   > >   
   >    
   > > - Show quoted text -   
   >    
   >    
   >    
   > Thank you. I tried to thank you before but they said too many post!   
   >    
   > I've never been on a post like the other one, lots great suggestions   
   >    
   > and hard work! I thank one and all!   
   >    
   > David   
      
      
      
   Hi all, I got this from stackoverflow.. user Joey has the credits, it works   
   for me.   
       
      
   1.Iterate recursively over the files:   
   for /r %F in (*)   
      
      
      
   2.Find out zero-length files:   
   if %~zF==0   
      
      
      
   3.Delete them:   
   del "%F"   
      
      
      
   Putting it all together:   
   for /r %F in (*) do if %~zF==0 del "%F"   
      
      
   If you need this in a batch file, then you need to double the %:   
   for /r %%F in (*) do if %%~zF==0 del "%%F"   
      
      
   Note: I was assuming that you meant files of exactly 0 Bytes in length. If   
   with 0 KB you mean anything less than 1000 bytes, then above if needs to read   
   if %~zF LSS 1000 or whatever your threshold is.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|