Topic "Renaming file after downloading with today's date?"

Author Message
Mikedu

Guest


Hi, I am using WinSCP for SFTP and it is working beautifully. I reference a txt file (see code below) and I call if from an SSIS package. The last thing I want to do is rename the source file to filename_todaysdate.txt. I have tried %date% but it just puts %date% in the filename, not the actual date. Any suggestions would be appreciated...

# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open login:pwd@IPAddress:Port
# Change remote directory
cd /home/emppfu/downloads
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
get CDS_STAGE.txt "\\Entp14\empgroup\BSG\CDS Balancing\ToBeProcessed\"
# Disconnect
close
# Exit
exit
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
This example may help you:
http://winscp.net/eng/docs/script_download_timestamped_filename
_________________
Martin Prikryl
mikedu

Guest


I called it from my execute process task in ssis and it gave me a ton of errors...sorry I am a newbie to this...

I referenced the .txt file in the arguments line, so I replaced it with the example file (see below)

Executable: C:\Program Files\WinSCP\WinSCP.com
Arguments: -script=C:\download.js
Working directory: C:\Program Files\WinSCP
mikedu

Guest


just trying to rename the file with today's date using script commands and it didn't work.

mv CDS_STAGE.txt %date:~4,2%-%date:~7,2%-%date:~10,4%.txt
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
mikedu wrote:
Executable: C:\Program Files\WinSCP\WinSCP.com
Arguments: -script=C:\download.js
Working directory: C:\Program Files\WinSCP

.js is WSH script, not WinSCP script
http://winscp.net/eng/docs/guide_automation_advanced#wsh
_________________
Martin Prikryl
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