Solved

How to hide a folder based on file size minimum

Posted on 2010-08-24
4
584 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

23 Experts available now in Live!

Get 1:1 Help Now