Solved

removing files under a certain size using batch

Posted on 2010-11-11
8
260 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 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 34122303
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
ID: 34122542
this worked but I had to remove the quotes around "\battlequest\"

are they needed for anything?
0
 

Author Comment

by:icecom4
ID: 34122569
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 69

Expert Comment

by:Qlemo
ID: 34122632
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
 

Author Comment

by:icecom4
ID: 34122936
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 69

Expert Comment

by:Qlemo
ID: 34123049
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
ID: 34125705
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 69

Expert Comment

by:Qlemo
ID: 34125845
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2 windows xp desktops computer 8 154
Application Not Found 3 102
Virtual PC for Windows 10 18 250
Best practices power settings GPO Win 10 4 106
Most of the time we are in fix when all of sudden our systems behave weirdly.  Such problems cost time and effort... so it's best to take some preventive actions so that we can avoid such issues or overcome such problems more easily. Preventive M…
Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 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