Solved

Powershell Recursive File/Folder Scan

Posted on 2013-05-31
3
824 Views
Last Modified: 2013-05-31
Hi,

I've found this script but i've been trying to get it to sort files by creationdate/time but i can't get it to go through sub folders can anyone spot the issue

Param([string]$path, [string]$filter, [switch]$help)

Function Sort-Files ([string]$path,[string]$filter)
{
 Get-ChildItem -Path $path -Filter $filter | 
 Sort-Object -Property CreationTime
} #end Sort-Files

Function Get-HelpText
{
 $helpText = @"
DESCRIPTION:
  Sorts files by creation date. Accepts parameter for path and file type.
EXAMPLE:
  SortFilesInFolderByCreationDate.ps1 -path c:\fso -filter "*.txt"
  SortFilesInFolderByCreationDate.ps1 -p c:\fso -f *.txt
  SortFilesInFolderByCreationDate.ps1 c:\fso *.txt
"@
 $helpText
} #end Get-HelpText
# *** Entry point to Script ***

if($help) { Get-HelpText ; exit }
Sort-Files -path $path -filter $filter | 
Format-Table -property name, creationtime -AutoSize

Open in new window

0
Comment
Question by:Alex Young
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 500 total points
ID: 39210197
Instead of :
Get-ChildItem -Path $path -Filter $filter

User:
Get-ChildItem -Path $path -Filter $filter  -recurse
0
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 500 total points
ID: 39210204
If you dont want to include the folder names in the result list, use:

Get-ChildItem -Path $path -Filter $filter -recurse -file
0
 
LVL 1

Author Closing Comment

by:Alex Young
ID: 39210240
Thank You
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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