Solved

removing files under a certain size using batch

Posted on 2010-11-11
8
259 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

770 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