Link to home
Start Free TrialLog in
Avatar of Alex Young
Alex YoungFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell Recursive File/Folder Scan

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

ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alex Young

ASKER

Thank You