1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

List Directory and files

Discussion in 'Windows Server 2003 / 2008 / 2012 / 2016' started by Chopperchand, Jun 7, 2012.

  1. Chopperchand

    Chopperchand Nibble Poster


    Wondering if someone can point me in the right direction

    We have a users directory on a server which has folders for each user on the network which as you can imagine has turned into a dumping ground

    basically what I need to do is get a list of the folders + there content (files) and the file sizes + owners of these files.

    I have seen it in explorer but is there a way to get this information in one go.. in a report or spreadsheet. I guess I would need software?? any ideas

    WIP: MCSA Sql Server 2012
  2. SimonD
    Honorary Member

    SimonD Terabyte Poster

    Do something like DIR /a /s /Q >files.txt from the root of the folder. The /a determines all files, /s does subfolders and the /Q shows the owner of said file\folders, the > puts it into a file for you (in this case files.txt).
    Certifications: CNA | CNE | CCNA | MCP | MCP+I | MCSE NT4 | MCSA 2003 | Security+ | MCSA:S 2003 | MCSE:S 2003 | MCTS:SCCM 2007 | MCTS:Win 7 | MCITP:EDA7 | MCITP:SA | MCITP:EA | MCTS:Hyper-V | VCP 4 | ITIL v3 Foundation | VCP 5 DCV | VCP 5 Cloud | VCP6 NV | VCP6 DCV | VCAP 5.5 DCA
    WIP: VCP6-CMA, VCAP-DCD and Linux + (and possibly VCIX-NV).
  3. GSteer

    GSteer Megabyte Poster

    Certifications: BSc. (Comp. Sci.), MBCS, MCP [70-290], Specialist [74-324], Security+, Network+, A+, Tea Lord: Beverage Brewmaster | Courses: LFS101x Introduction to Linux (edX)
    WIP: CCNA Routing & Switching
  4. Gav

    Gav Kilobyte Poster

    It's nowhere near as neat as SimonD's example, but you could get a more searchable, CSV-based, report with PowerShell. Replace the parts in bold as required...

    $array = @()
    foreach ($File in (Get-ChildItem "[B]C:\Folder\[/B]" -Recurse | where {$_.Attributes -notlike "Directory"})) {
    $LoopOut = New-Object PSObject
    $LoopOut | Add-Member -MemberType NoteProperty -Name "ParentFolder" -Value $File.DirectoryName
    $LoopOut | Add-Member -MemberType NoteProperty -Name "FileName" -Value $File.Name
    $LoopOut | Add-Member -MemberType NoteProperty -Name "FileSize (KB)" -Value ("{0:N2}" -f ($File.Length / 1024))
    $LoopOut | Add-Member -MemberType NoteProperty -Name "Owner" -Value (Get-ACL $File.FullName).Owner
    $Array | Export-CSV [B]Report.csv[/B] -NoTypeInformation
    Last edited by a moderator: Jun 9, 2012
  5. Boffy

    Boffy Megabyte Poster

    Thanks GSteer, couldn't remember the software name! WinDirStat is awesome!
    Certifications: BSc Computer Game Technology, A+
    WIP: MOS 2010
  6. Chopperchand

    Chopperchand Nibble Poster

    Thanks Guys,

    I am trying to sort out the file from the dir command,

    WinDirStat gives good information, but the problem is user not cleaning up there folders them self's. so can email then the folder usage.

    basically wanted to send users a list of the files from there folder older then 4years and tell them this is going to be archived or deleted do you still want these files!!

    Things you have to do for users.

    Thanks for all your suggestions.
    Last edited: Jun 13, 2012
    WIP: MCSA Sql Server 2012

Share This Page