Sorting a remote directory

Advertisement

JonWayn70
Donor
Joined:
Posts:
9
Location:
Bellingham, WA

Sorting a remote directory

Is there a way to sort a remote directory, using a script command, so that the ls command will return the listing in the order you want? Thank you

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Sorting a remote directory

You better use WinSCP .NET assembly (e.g. from PowerShell) if you want to customize the output anyhow.
For an example, see:
https://winscp.net/eng/docs/script_custom_listing_format_csv

For sort the file for example by time, use:
$directory = $session.ListDirectory($remotePath)
$files = $directory.Files | Sort-Object LastWriteTime -Descending
foreach ($fileInfo in $files)
{
    ...
}

Reply with quote

Advertisement

You can post new topics in this forum