Solved

How to hide a folder based on file size minimum

Posted on 2010-08-24
4
603 Views
Last Modified: 2012-05-10
Hello, I'm hoping someone can help me out.

I'm trying to figure out how to hide folders whose contents are less than 200mb in size. I want to run this script on a schedule and have it

Scan the directory E:\--TV--\

Cycle through each top level folder in the directory and determine folder contents space

< 200mb in size = Hide
> 201mb in size = Visible

Can someone point me in the right direction or help out?

Thanks

Josh
0
Comment
Question by:JoshFink
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Assisted Solution

by:roarkinc
roarkinc earned 250 total points
ID: 33514350
you can do this with a batch script

this will get you the folder size including subfolders:

@For /F "tokens=*" %%a IN ('"dir /s /-c | find "bytes" | find /v "free""') do @Set summaryout=%%a
@Echo %summaryout%
@For /f "tokens=1,2 delims=)" %%a in ("%summaryout%") do @set filesout=%%a&set sizeout=%%b
@Echo %filesout%
@Echo %sizeout%
@Set sizeout=%sizeout:bytes=%
@Echo %sizeout%
@Set sizeout=%sizeout: =%
@Echo Size is :%sizeout%

this is what you can use to hide the folder

attrib +h folderName

to unhide us
attrib -h folderName
0
 
LVL 13

Accepted Solution

by:
soostibi earned 250 total points
ID: 33514385
This is PowerShell solution:
$fs = New-Object -ComObject scripting.filesystemobject
Get-ChildItem E:\--TV--\ -force | Where-Object {$_.psiscontainer} | ForEach-Object {
	if($fs.getfolder($_.fullname).size -lt 200mb) {$_.attributes = "directory,hidden"}
	else{$_.attributes = "directory"}
}

Open in new window

0
 

Author Comment

by:JoshFink
ID: 33517584
Question -- Does the above Powershell script also hide the main directory? E:\--TV--? If so how do I prevent that?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33518866
No, it hides only subfolders, but it does not hide subfolders of subfolders.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

623 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