Topic "date variable in script file"

Author Message
murrayb3024

Guest


We create a daily file that I need to upload to a vendor. I can hard code the file name and that works but it changes daily so I need to send a file like:

c:\myfilepath\myFile_20130122.txt where the date portion changes daily and needs to be yyyymmdd.

I am not having luck with that part. Any help is appreciated.
Advertisements
murrayb3024

Guest


This is all done from a text file script.
murrayb3024

Guest


Disregard figured it out
mjb0622

Guest


Does anyone have a sample of this solution. I am trying to do the same with a date.
The file name cahnages by day and i need to update several systems with the same file.
How do I pass the date to the text file?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
mjb0622 wrote:
Does anyone have a sample of this solution. I am trying to do the same with a date.
The file name cahnages by day and i need to update several systems with the same file.
How do I pass the date to the text file?

See example here.
https://winscp.net/eng/docs/script_download_timestamped_filename
Or even better, use WinSCP .NET assembly:
https://winscp.net/eng/docs/library
_________________
Martin Prikryl
Guest




You can configure date variables in a dos box. Once you prepare the date format you need, then set it to a variable name. Then you can use it as part of the filename to either send or get.
From within te bat file, you can call winscp to open an sftp while passing the date variable to the winscript. Be sure to enclose it with % signs.

Dos date format is mm/dd/yyyy (10 characters). This was run in a dos prompt. The set date is just to test any date you want.
C:\>set date=04/01/2013
C:\>echo %date%
04/01/2013
C:\>set dtmm=%date:~-10,2%
C:\>set dtdd=%date:~-7,2%
C:\>set dtyyyy=%date:~-4,4%
C:\>echo %dtmm%
04
C:\>echo %dtdd%
01
C:\>echo %dtyyyy%
2013
C:\>set dteall=%dtyyyy%%dtmm%%dtdd%
C:\>echo %dteall%
20130401
C:\>
So you can use %dteall% as part of a filename: myfile%dteall% = myfileyyyymmdd
The variable can be used in your winscript if needed.
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