Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

windows batch delete script

Posted on 2011-10-21
4
Medium Priority
?
257 Views
Last Modified: 2012-05-12
Hello all.  I need script similar to the one below which searches for files beginning with z and deletes them if less than a certain file size but...

unlike the script below, I have a known directory and I do not want to search the whole hard drive to save time.  

so the the script should delete all files that start with z, and LSS 7043000 , from this known path
c:\program files\main\qagame\

example...
 set folder=
for %%D in (C D E F G H I J K) do (
  for /F "tokens=*" %%P in ('if exist %%D: dir /a:-d /s/b %%D:\~* ^| findstr /L /i \qagame\') do (
      if %%~zP LSS 7043000 del /s /q "%%~P"
  )
)
0
Comment
Question by:icecom4
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
d_nedelchev earned 1000 total points
ID: 37007015
This should do the trick:

@echo off

cd /D "c:\program files\main\qagame\"


for /F "tokens=* delims=" %%i in ('dir z*.* /b /s') do IF %%~zi LSS 7043000 del /q /f "%%i"
0
 

Author Comment

by:icecom4
ID: 37009043
hey this works thanks.  Just curious...would     ~*.zip  mean only zip files that start with ~ ?  Because I will want to make that small change.  
0
 
LVL 5

Expert Comment

by:d_nedelchev
ID: 37009162
Yes.
0
 

Author Closing Comment

by:icecom4
ID: 37009225
worked like a charm!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

804 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question