Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page




Reference number: CH000754

Deleting files equal to 0 in a batch file.

Question:

Deleting files equal to 0 in a batch file.

Additional information:

Users who wish to keep their system clean from any files that have no data within them or delete files once data has been removed may need to delete a file equal to 0 from a batch file.

Answer:

Below is an example of a simple for command that could be put into a batch file to delete the "pics.txt" file if it existed and was equal to 0. In this example you would need to know what file you're looking for.

for /F %%A in ("pics.txt") do If %%~zA equ 0 del pics.txt

If you are looking for all files equal to 0 you would need to create a loop and a similar command for this to work is shown below.  

FOR %%F IN (*.*) DO (
IF %%~zF LSS 1 DEL %%F
)

The above example will go through all files in the current directory, and if less than 1 in file size, delete the file.

See our for command page for additional information about this command.

 

 

 

Index


Category:
Batch file help

Companies:
Microsoft

Related Pages:

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope