Perl WinSCP .Net Assembly Script via Win32::OLE , Sort the Output by File Name or Mod Date?
Hello Martin & WinSCP Support,
I have a Perl script that is succesfuly pulling in all of the WinSCP data for an SFTP site I'm downloading files from.
Open a session via a Perl script that uses Win32::OLE:
Is there an easy way to sort the list of files that come from this, via Perl Win32::OLE, without extrapolating all of the data into date or file name logic?
I see your examples with PowerShell:
For sort the file for example by time, use:
How can I replicate the
thanks,
Joe P.
I have a Perl script that is succesfuly pulling in all of the WinSCP data for an SFTP site I'm downloading files from.
Open a session via a Perl script that uses Win32::OLE:
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); my $session = Win32::OLE->new('WinSCP.Session') || warn "Can't create winscp session: ", Win32::OLE->LastError; my $consts = Win32::OLE::Const->Load($session); my $sessionOptions = Win32::OLE->new('WinSCP.SessionOptions')|| die "Can't open winscp session Options: ", Win32::OLE->LastError; $sessionOptions->{'Protocol'} = $consts->{'Protocol_Sftp'}; $sessionOptions->{'HostName'} = $ProgramRemoteSFTPSettings::RemoteSFTPServer; $sessionOptions->{'UserName'} = $ProgramRemoteSFTPSettings::DOWNLOAD_USER; $sessionOptions->{'Password'} = $ProgramRemoteSFTPSettings::DOWNLOAD_USERPASSWD; $sessionOptions->{'SshHostKeyFingerprint'} = $ProgramRemoteSFTPSettings::DestServerFingerPrintKey; $session->Open($sessionOptions); my $directory = $session->ListDirectory("${FileContent::FileSFTPLoc[$i]}"); my $items = Win32::OLE::Enum->new($directory->{'Files'}); my $item; while (defined($item = $items->Next)) { my $FilePermissionsHash = $item->{'FilePermissions'}; my $FilePermissions = $FilePermissionsHash->{'Text'}; }
I see your examples with PowerShell:
For sort the file for example by time, use:
$directory = $session.ListDirectory($remotePath) $files = $directory.Files | Sort-Object LastWriteTime -Descending foreach ($fileInfo in $files) { ... }
$files = $directory.Files | Sort-Object LastWriteTime -Descending
?
thanks,
Joe P.