Solved

removing files under a certain size using batch

Posted on 2010-11-11
8
253 Views
Last Modified: 2012-05-10
I am intetested in removing files under a certain size from any directory with a certain name.  So for instance, I want the batch to search multiple drives for folders called "battlequest" and delete any files in those folders under a certain size.  Below is an example of a working script that removes certain size files from a known path, perhaps that can help get you started.  

thanks in advance

pushd "f:\Program Files\games\battlequest"
for %%j in (*.pk3) do if %%~zj lss 1043000 del "%%~j"
0
Comment
Question by:icecom4
  • 4
  • 4
8 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
Based on http:/Q_26601351.htm:
set folder=

for %%D in (A B C D E F G H I J K L M N O P Q R S T U V W X Y) do (

  for /F "tokens=*" %%P in ('dir /a:-d /s/b %%D:\*.pk3 ^| findstr /L /i "\battlequest\"') do (

      if %%~zP LSS 1043000 del /s /q "%%~P"

  )

)

Open in new window

0
 

Author Comment

by:icecom4
Comment Utility
this worked but I had to remove the quotes around "\battlequest\"

are they needed for anything?
0
 

Author Comment

by:icecom4
Comment Utility
ok and lastly, is there a command that will make the batch script activity invisable when active?  I know how to minimize the script window "/min" and clear "cls", but any other way to make it not visable to users that execute it?
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Not really. Hiding such a window is often considered malicious by AV software. A tool to hide a running window is CmdOW (http://www.commandline.co.uk/cmdow/). You cannot hide the Window from start - for that you would need to start the batch file from e.g. VBS.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:icecom4
Comment Utility
ok thanks.  the reason I am asking is because I am developing scripts to removed crappy menus forced on game users by some servers which players concider malicious.  The reason I dont want the script visable is because these server owners will view my script and try to bypass it.  But no worries.  

You mentioned that AV software may concider a script malicious.  Thats cool, so then I won't hide the windows.  Is there anything I should avoid putting in batch scripts that will trigger an AV alert?  I dont want a simple script to be blocked by AV.  

thanks again
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Nothing of above will alert an AV. What can be problematic is
contacting an IP address, in particular with http or telnet - considered as very suspicious
accessing system32 folder
using applications containing a just-in-time decompression part
using Remote Control software
using software known to be capable of hiding, resizing, moving of windows
and some more.
0
 

Author Comment

by:icecom4
Comment Utility
I ping a local ip to create a delay.  Is that ok for AV?  

example:  ping 123.45.67.89 -n 1 -w %11500 > nul
ECHO.  done

thanks and I will close after this.  
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
That is ok, though the   -w %11500   looks strange. I guess it is to add a multiplier of 10 secs as an option if provided on the commandline.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now