As seguintes obras (um pouco grosseiramente) em Powershell
[CmdLetBinding()]
Param(
[string]$Path,
[string]$extension = "*"
)
If ($Path.ToString().Substring($Path.Length-1,1) -eq "\")
{
$Path = $Path.ToString().Substring(0,$Path.Length -1)
}
If ($Extension[0] -eq ".")
{
$Extension = $Extension[1..$Extension.Length] -join ""
}
$dirlisting = cmd /c "dir \?\$path\*.$extension /s /-c /t:a"
ForEach ($line in $dirlisting)
{
if ($line -match "^ Directory of (.*)$")
{
$FolderName = $matches[1] -replace "\\\?\",""
} ElseIf ($line -match "(\d{2}/\d{2}/\d{4})\s+?(\d{2}:\d{2})\s+?(\d+?)\s+?(.+)$")
{
$DateAndTime = [datetime]::Parse($matches[1] + " " + $matches[2])
$Filesize = $matches[3]
$FileName = Join-Path -Path $FolderName -ChildPath $matches[4]
$FileObject = New-Object PSCustomObject -Property @{
FullPath=$FileName
LastAccessTime=$DateAndTime
FileSize=$FileSize
}
Write-Output $FileObject
}
}