Post a reply

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)


Topic review


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
$files =
         $remotePath, $Null, $opts) |
     Where-Object { $_.IsDirectory -and ($_.LastWriteTime -gt $limit) } |
     Select-Object -ExpandProperty FullName

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 =
      $remotePath, $mask, [WinSCP.EnumerationOptions]::MatchDirectories) |
   Select-Object -ExpandProperty FullName               
echo $files

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