InterviewSolution
| 1. |
Solve : Deleting files equal to 1KB in a batch file? |
|
Answer» How to create a script to delete files (ej.: *.xml or *.html) equal to 1KB in batch file?Did you mean files whose size is exactly 1024 bytes? Not more? Not less? Files 2.xml, 4.xml, 6.xml, 8.xml are files of 1KB to windows. In the DETAILS view, Windows EXPLORER rounds file SIZES, roughly to the nearest 1 KB. Files under 1024 bytes are shown as "1 KB". The file 2.xml is in fact 115 bytes in size as you can see. so are 4, 6 and 8.xml. Quote File Not Found Is the batch file in the same folder? Yes, the batch file name is del.batQuote from: mdibarra on December 07, 2010, 01:40:20 PM Yes, the batch file name is del.bat And the .xml files are in the same folder? Are they hidden, system or read-only? What HAPPENS if you run this batch in that folder? Code: [Select]@echo off echo. echo This file is %~dpnx0 echo. echo 1 for /f "delims=" %%A in ('dir /b *.*') do echo File %%A %%~zA bytes echo. echo 2 echo. for /f "delims=" %%A in ('dir /b *.xml') do echo File %%A echo. echo Finished |
|