Input filename condition from user at beginning of script.

Advertisement

crawly
Guest

Input filename condition from user at beginning of script.

I have to download a number of files on a weekly basis from a ftp. The filenames remain the same from week to week except there is a date code added to the file. eg "image22.tif", where 22 is the week number. Naturally the file next week would be called "image33.tif". Would there be a way to prompt the user at start up for the we number, in this case "22", and then merrily go off and download all the files I need. Think this would be possible?

Reply with quote

Advertisement

crawly
Guest

Correction plus possible solution....

A correction to the original post... the second file should have been named "image23.tif", not "image33.tif". Also "prompt the user at start up for the we number" should have read "prompt the user at start up for the week number".

So, aside from all that. I was going through some example scripts and one was checking the timestamp of the remote files. So how about I just get the script to calculate the current week and add it to the file name string and just like the example if it is there, download it, if not, then write that the file does not exist yet.

Reply with quote

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

Re: Input filename condition from user at beginning of script.

WinSCP script does not support any kind of custom prompting nor calculation.

You can however prompt user from wrapping batch file and pass the answer to WinSCP script.
See https://stackoverflow.com/q/1223721/850848

To access the entered value from the script, either store it to environment variable or pass it using /parameter switch.
See https://winscp.net/eng/docs/scripting#syntax

Reply with quote

Advertisement

You can post new topics in this forum