Batch File that finds and deletes if contains

May 18, 2011 at 08:38:05
Specs: Windows 7
Hellow there, i want to create a batch file that deletes junk from my computer...
I have thousands of new text files...
What is the Batch script that deletes files that do not contain any info?
I'm not a noobie at Batch, so I will understand the script...
Thanks...

See More: Batch File that finds and deletes if contains

Report •


#1
May 18, 2011 at 08:53:27
Define "do not contain any info"

How To Ask Questions The Smart Way


Report •

#2
May 18, 2011 at 09:05:28
OK I lied... :)
I need a file that checks the "C:\" drive for empty txt files and deletes them...
Sorry for my bad english I am from Lithuania...

Report •

#3
Report •

Related Solutions

#4
May 18, 2011 at 14:15:55
If you don't feel safe downloading strange executables off of some stranger's website, try the following batch script:
for /r c:\ %%a in (*.txt) do @if "%%~Za"=="0" @del "%%a"

EDIT: You might need to run the script as administrator, depending on where these files reside.

How To Ask Questions The Smart Way


Report •

#5
May 28, 2011 at 00:54:03
I get error saying that "%%a was unexpected|"... What to do?

Report •

#6
May 29, 2011 at 08:50:39
If you're running it from the command prompt manually instead of from a script, replace every %% with %

How To Ask Questions The Smart Way


Report •

#7
May 29, 2011 at 13:59:54
Before posting Access is denied error Read below note once again...Just reminding as you forget Rozer said to run from batch file and you ran from CMD shell directly..

EDIT: You might need to run the script as administrator, depending on where these files reside.

C:\ is a protected folder and without Admin options UAC wont allow the batch script or command shell to modify root of the it (C: )

Subhash Chandra.
http://www.wintechgeek.com


Report •

#8
May 30, 2011 at 23:23:33
try this one

for /f "delims= " %%a in ('dir /a c:\test.txt /b /s') do del =%%a

pause
where test.txt is the name of your file('s)


Report •


Ask Question