Solved

Need a VBscript that can scan all the folders for Created and modified files by variable date.

Posted on 2014-09-25
9
278 Views
Last Modified: 2014-10-25
I have a need to control a repository folder size with thousands of users using it. We need a VBscript that can scan all the folders for Created and modified file with in variable time periods. Such as last 24 hours. Add write out to file. Some teams are adding to many files and we just want to know who they are by reviewing there teams subfolder under the main teams repository folder.
0
Comment
Question by:williamfl
9 Comments
 

Author Comment

by:williamfl
ID: 40344288
We would like the output file to show the file sizes also so we can identify the team using the most space.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40345455
Using Powershell would be the best option here.  There's a good article here:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/25/getting-directory-sizes-in-powershell.aspx

that should give you something close to what you need.

Rob.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40345464
gci  c:\folder -recurse | where {(!($_.PsIsContainer)) -and $_.CreationTime -gt (Get-Date).AddDays(-1)} | select Fullname, Length | export-csv report.csv -ntigci c:\folder -recurse  | {where $_.CreationTime - lt (get-Date).AddDays(-1)}

Open in new window

0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 70

Expert Comment

by:Chris Dent
ID: 40345492
Bit messy on the end of your example there becraig, copy and paste problems by the looks of it. It might be a good idea to repost it.

I would add that:

> with thousands of users using it

You'll almost certainly hit the native path length limitation in .NET (260 characters). It's possible to work-around the limitation by creating temporary drive mappings or junctions, it's just quite deeply unpleasant (in my opinion).

Chris
0
 
LVL 29

Accepted Solution

by:
becraig earned 500 total points
ID: 40345508
Very true Chris :~)

Methinks some sleep is needed:

Here is a cleaned up version:
gci  -recurse | where {(!($_.PsIsContainer)) -and $_.CreationTime -gt (Get-Date).AddDays(-1)} | % {
$report = New-Object PSObject
$report | Add-Member -membertype NoteProperty -Name FileName -Value $_.Name
$report | Add-Member -membertype NoteProperty -Name ParentFolder -Value $_.DirectoryName
$report | Add-Member -membertype NoteProperty -Name Size -Value (("{0:N4}" -f ($_.length / 1MB) + "MB"))
}
$report | export-csv reports.csv -NoTypeInformation

Open in new window

0
 
LVL 45

Expert Comment

by:aikimark
ID: 40345849
You could also use Robocopy
Example:
robocopy sourcepath andvalidpath /L /minage:0 /maxage:1

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40346318
Ok I'm awake now:

I've added the file owner/creator as well as the option for files modified in the past day as well as files created in the past day.

A quick overview of what the powershell script below does:
The first line gci -recurse checks the current folder and all child folders (You need to replace "gci  -recurse " with "gci \\share\folder -recurse")
The output is piped into a foreach loop and the output objects are created then piped to the export-csv command.


gci  -recurse | where {(!($_.PsIsContainer)) -and ($_.CreationTime -gt (Get-Date).AddDays(-1) -or $_.LastWriteTime  -gt (Get-Date).AddDays(-1))} | % {
$report = New-Object PSObject
$report | Add-Member -membertype NoteProperty -Name Owner ((Get-ACL $_.FullName).Owner)
$report | Add-Member -membertype NoteProperty -Name FileName -Value $_.Name
$report | Add-Member -membertype NoteProperty -Name ParentFolder -Value $_.DirectoryName
$report | Add-Member -membertype NoteProperty -Name Size -Value (("{0:N4}" -f ($_.length / 1MB) + "MB"))
}
$report | export-csv reports.csv -NoTypeInformation

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40347682
Have you tested the script ?

Are there any issues to address ?
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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