Topic "Get files Based on date what you want (SFTP connection)"

Author Message
ebensalot
[View user's profile]

Joined: 2016-06-27
Posts: 1
Location: Phillipines
Good day Winscp Supports,

I want to copy a file from the server based on date user inserted

this is the script I used but all files will get not the the date I input:

this is the .bat file to call the winscp script:


@echo off

:main
echo Inputdate(YYYYMMDD)
set /p car=
if %car% == 1 goto date

mkdir "C:\Documents and Settings\asd\Desktop\%car%"
WinSCP.com /script=sample.txt
pause


And this is the winscp script:

option batch abort
option confirm off


open sftp://username:password@Ip ADd -hostkey="ssh-rsa 2048 c5:89:02:bd:ce:66:ec:18:e2:10:b6:40:2f:81:a0:a6"


get -filemask="*>=%TIMESTAMP#yyyy-mm-dd%" /media/4B90C3C70BA785A7/melvin.luching C:\SMARTVISTA\%car%

exit
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
You have to use the car in your -filemask. And the car has to be in format YYYY-MM-DD, not YYYYMMDD:

get -filemask="*>=%car%" /media/4B90C3C70BA785A7/melvin.luching C:\SMARTVISTA\%car%
Guest




martin wrote:
You have to use the car in your -filemask. And the car has to be in format YYYY-MM-DD, not YYYYMMDD:

get -filemask="*>=%car%" /media/4B90C3C70BA785A7/melvin.luching C:\SMARTVISTA\%car%


Hi Sir Martin.

How to get the files only that I inserted date. because this script give me a all files after the inserted date
eg: i want to get 05-30-2016 but the script was getting from 05-30-2016 up to date today.

Thanks,
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
get -filemask="*>=%car%<=%car% 23:59:59" /media/4B90C3C70BA785A7/melvin.luching C:\SMARTVISTA\%car%[/quote]
Guest




martin wrote:
get -filemask="*>=%car%<=%car% 23:59:59" /media/4B90C3C70BA785A7/melvin.luching C:\SMARTVISTA\%car%



Hi Sir,

I Cant copy the file inside the folder of the date I input this is the script I used:

get -filemask="*>=%car%<=%car% 23:59:59" /media/4B90C3C70BA785A7/melvin.luching/copy1tolocal/reports/%car% C:\SMARTVISTA\%car%\reports

the filename format of the folder is 03302016 but the date format need to Input in my script is YYYY-MM-DD format, when I try to change that to MMDDYYYY I can copy the folder but the file created in the input date didn't copy.

I uploaded the picture of the directory of my ftp server thanks,

Melvin.
winscp.jpg (56.75 KB)

Description: (none)

winscp.jpg

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
So just convert one format to the other.

Like:

Code:
echo Inputdate(YYYY-MM-DD)
set /p CAR=
set CAR_MMDDYYYY=%CAR:~5,2%%CAR:~8,2%%CAR:~0,4%


See http://ss64.com/nt/syntax-substring.html

Though this has no longer anything to do with WinSCP.
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