This is my code getting the server date yesterday.

```
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set /A "DD=(%dt:~6,2%)-1"
set datestamp=%YYYY%%MM%%DD%
set RunDate=%datestamp%

```

---

However, I'm trying to add this condition in this syntax:

```
"C:\Program Files (x86)\WinSCP\winscp.com" /console ^
  /command "open sftp://Username:Password]@port" "cd /Dir" "put Dir\.CSV file" pause exit 

```

---

So it will be:

```
C:\Program Files (x86)\WinSCP\winscp.com /console /command 
open sftp://USER:PASS]@IP
cd Dir
@echo off
setlocal
del Dir\Script.txt
echo User>>Dir\Script.txt
echo Pass>>Dir\Script.txt
echo passive>>Dir\Script.txt
echo prompt>>Dir\Script.txt
echo cd Dir>>Dir\Script.txt
echo binary>>Dir\Script.txt 

for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do 
set 
"dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set /A "DD=
(%dt:~6,2%)-1"
set datestamp=%YYYY%%MM%%DD%
set RunDate=%datestamp%
echo %RunDate%
echo put Dir_%RunDate%.csv>>Dir\Script.txt

echo close>>Dir\Script.txt

pause 
exit  /b

```

---

I'm trying to add the variable: `%RunDate%` to any `.csv` file (Yesterday date with format) to upload it to the SFTP.