Topic "Most recent file selection with WinSCP command line"

Author Message
sivaramanm
[View user's profile]

Joined: 2013-11-19
Posts: 5
How do i achieve this using winscp command line automation commands?

https://winscp.net/eng/docs/script_download_most_recent_file
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26515
Location: Prague, Czechia
Your duplicate question on stackoverflow:
https://stackoverflow.com/q/22388746/850848

Quote:
You cannot do this on command-line only. If it was possible, the solution in WinSCP documentation would show it instead of the use of wrapper script.

The closest you can get with command-line only is using file mask with time constraint. For example, if you know that one file per day is added only, you can use *>1D mask to select files (one file actually) created within the last 24 hours.
Andreb

Guest


sivaramanm wrote:
How do i achieve this using winscp command line automation commands?

https://winscp.net/eng/docs/script_download_most_recent_file


Hi All... Please please can somebody help me - I'm struggling my ╤╚♦ off Smile
I have files - 6 of them sitting on a remote site, every day a new is placed, I need to download only the newest one, the file name changes every day to I'm aiming at using the "latest date" - needless to say my scripting knowledge is void - I've tied using the >1d - WinSCP does all sorts of weird things and gives me a file called %3C1d - what the hell is that??

my command currently reads "get //ftp05155/FTP*.* <1d"

Please can someby please assist with the correct syntax that would allow me to automate the download of the latest file between 6 others from the SFTP please - connectivity is working, just the download seems to be problematic....

thanks a Huge load for your efforts, much appreciated!
Andre
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26515
Location: Prague, Czechia
Andreb wrote:
my command currently reads "get //ftp05155/FTP*.* <1d"

There should be NO space between *.* and the time constraint + It should be >, not <.
Are you sure the path should start with two slashes?

Btw, it would be nice, if you accept the answer you got on stackoverflow.com.
SLee

Guest


I know its really old post , but I had similar requirement, and what worked for me is : get /out/abc.z*>16h %LOCAL_PATH% where abc.zip was my exact file name in out folder. It got me only abc.zip.
pgpsatish@...

Guest


Hello,

I'm trying to use below WinSCP script in a MSDOS batch file to automatically download the ZIP files from FTP server. I need to automatically download files every 2 hours from the FTP server.

Code:
"C:\Program Files\WinSCP5.7\WinSCP.com" ^
  /log="C:\Program Files\WinSCP5.7\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://electpub:elmelm5@obp-ftp.oxon.blackwellpublishing.com/" ^
    "get *.zip /ElecMediaOUT/ -filemask>=2H  H:\FTP-Blackwell\" ^
    "exit"



I get error as below

. 2017-07-20 12:16:16.578 Retrieving file information successful
< 2017-07-20 12:16:16.578 Script: Can't get attributes of file '/ElecMediaOUT/'.
< 2017-07-20 12:16:16.578 Script: File or folder '/ElecMediaOUT/Informatics/' does not exist.
. 2017-07-20 12:16:16.578 Script: Failed
. 2017-07-20 12:16:16.578 Script: Exit code: 1
. 2017-07-20 12:16:16.578 Disconnected from server

=============================

Pls let me know the correct syntax to be used for "get" with "filemask" script in a batch file.

I have attached log file for your quick ref

Thanks

Satish P
WinSCP.log (34.97 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26515
Location: Prague, Czechia
pgpsatish@... wrote:
Pls let me know the correct syntax to be used for "get" with "filemask" script in a batch file.

It should probably be:

"get /ElecMediaOUT/*.zip -filemask>=2H H:\FTP-Blackwell\" ^

Though your log file does not actually match the script, so it's hard to help you.
Advertisements

You can post new topics in this forum






Search

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