Topic "Batch File not reading Varibles"

Author Message
Apurv
[View user's profile]

Joined: 2013-12-27
Posts: 1
Location: Apurv
Hello,

I have created a batch script{below} that refers to Credentials file:
set Pathname="C:\Program Files\WinSCP"
pushd %Pathname%
winscp.com /script="D:\Test\Credentials.txt"


The files I am trying to extract come with date and a random stamp. All the files, including previous days files, are placed in same directory.
eg:
User_20131227_010203.txt
User_20131226_098778.txt
User_20131225_093110.txt

I have to extract latest files.I am trying to use 'User__%date:~-4,4%%date:~-7,2%%date:~-10,2%-*'
But SFTP commands don't seem to understand these variables.

Any way to extract latest files or read variables?
Any help is appreciated.

Thanks!
[/img]
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
WinSCP supports only basic syntax %NAME%, not the advanced syntax you are using.
Specifically, it is using ExpandEnvironmentStrings WinAPI function:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx

You can store the result of %date:~-4,4%%date:~-7,2%%date:~-10,2% to a temporary variable in your batch file and use that from the script.
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