Topic "How to get latest modified file?"

Author Message
LeonPix
[View user's profile]

Joined: 2006-08-15
Posts: 3
Hi,

How to get lastest modified timestamped file in remote folder using script?

Meaning, after "cd remote_folder", I wanna "get file", which this file has latest modification timestamp at remote directory.

Thank you!
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I do not understand what you ask for. Please try again Smile
_________________
Martin Prikryl
LeonPix
[View user's profile]

Joined: 2006-08-15
Posts: 3
Let's say after we connect to a remote sftp site. By doing "ll" we got this:

31/07/2006 20:16 2,417,200 file_a
31/07/2006 22:16 2,484,770 file_b
31/07/2006 24:16 2,484,770 file_c

Timestamp of file_c has the latest timestamp.

How can we write a script to download file_c which has the latest timestamp in this directory?

Do I make myself clear in this case? Thanks!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I do not see any nice solution. One of the ugly ways that come to my mind is:
Code:
# make copy of the latest file with unique extension,
# so that it can be grabbed by file mask
# (note that you can make the copy in /tmp if needed)
call cp `ls -t | head -1` `ls -t | head -1`.latest
# download the copy, but strip the extension
get *.latest *.
# remove the copy
rm *.latest
LeonPix
[View user's profile]

Joined: 2006-08-15
Posts: 3
thx! it's an inspiring answer Smile
sunn

Guest


I am trying to do the same thing but problem is I need to have during the week 1 file and oon the weekend I need 3 files.

I need to have them by timestamp so easier to get by date. What would the code look like.
sunn
[View user's profile]

Joined: 2011-07-04
Posts: 1
sunn wrote:
I am trying to do the same thing but problem is I need to have during the week 1 file and oon the weekend I need 3 files.

I need to have them by timestamp so easier to get by date. What would the code look like.


Also I am using
C:\Program Files\WinSCP\WinSCP.com Logininfo /script=C:\Downloads\myscript.txt

I would like to add more to the script or make a new script similar to what i am using ( basic get statement ). That file on the ftp are .gz and need to converted in excel or csv format.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License