Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to hide a folder based on file size minimum

Posted on 2010-08-24
4
Medium Priority
?
609 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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.
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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