Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: LastWriteTime of directory

The Session.EnumerateRemoteFiles supports only trivial file masks, definitely not time constraints.

You have to use RemoteFileInfo.LastWriteTime to select the desired folders:
$limit = [System.DateTime]::Today.AddDays(-1)
$opts =
    [WinSCP.EnumerationOptions]::AllDirectories -bor
    [WinSCP.EnumerationOptions]::EnumerateDirectories
$files =
     $session.EnumerateRemoteFiles(
         $remotePath, $Null, $opts) |
     Where-Object { $_.IsDirectory -and ($_.LastWriteTime -gt $limit) } |
     Select-Object -ExpandProperty FullName
MrRobot

LastWriteTime of directory

Hey there,

I want to select all remote subfolders with a specific LastWriteTime, in this case later than yesterday. I don't want to select the files in the folders, just the folder itself.
$mask = "*>=yesterday"
$files =
   $session.EnumerateRemoteFiles(
      $remotePath, $mask, [WinSCP.EnumerationOptions]::MatchDirectories) |
   Select-Object -ExpandProperty FullName               
echo $files

This does not work. Any idea on how to make this work?