Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

REF1133

Re: Date as part of filename

Thanks for your reply. We are using version 5.1.4 and I believe this is likely causing the issue. After looking through the version history, it seems that TIMESTAMP is not available in our version and that we will need to upgrade. I will try upgrading and then see if my code works.

martin wrote:

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
martin

Re: Date as part of filename

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
REF1133

Date as part of filename

Hello,

I am very new to WinSCP scripting. I need to be able to pull a file daily where the filename contains the date and therefore is different each day. I have created the following scripts that successfully pull a hard coded filename. After searching through the forum, I thought that using %TIMESTAMP#yyyymmdd% would allow for a dynamic date in the filename. I have this code commented out below. It does not work, though, and does not produce an error. Thanks in advance for assistance!

Command script:
REM Pull file from SFTP and place in directory
"F:\data tasks\winscp.com" /script="F:\data tasks\pull_file_from_daily_sftp.txt"

pull_file_from_daily_sftp.txt:
# Automatically abort script on errors
option batch continue

# Disable overwrite confirmations that conflict with the previous
option confirm off

# Connect
open XConnection

# Force binary mode transfer
option transfer binary

# Download
get -filemask="DAILY_20180410.zip" /current/daily/files/ "F:\Data Imports\daily\"
#get -filemask="DAILY_%TIMESTAMP#yyyymmdd%.zip" /current/daily/files/ "F:\Data Imports\daily\"

# Disconnect
close
exit