dateftptimestampsftpwinscp

Altering WinSCP timestamp, get file(s) from a specified date-named folder


I have a directory that has multiple folders that are date-named YYYYMMDD and they have text file(s) in them.

I want to be able to get the files from the folder that was named with the date 5 days ago.

The script below gets the current date named folder by using %TIMESTAMP#yyyymmdd%:

get "/some/random/path/%TIMESTAMP#yyyymmdd%/*.txt" "C:\receivables\"

For instance, let's say today is 20180724. It will get all the text file(s) from the folder named 20180724; however, I want it to get the text file(s) from the folder named 20180719 which will be 5 days previous. How do I approach this?


Solution

  • WinSCP %TIMESTAMP% syntax supports relative times. So you can use:

    get "/some/random/path/%TIMESTAMP-5D#yyyymmdd%/*.txt" "C:\receivables\"