Topic "Help with scripting (use of variables and download)"

Author Message
[View user's profile]

Joined: 2011-10-27
Posts: 1
Location: Maryland
WinSCP Version: 4.3.5, Build 1463
Windows version: XP SP3
Transfer Protocol: SFTP (SCP)
Method: Scripting Automation (command line)

Question(s): I am brand new to WinSCP and want to automate a download from each of 500 folders on the server. Is there a way to use variables within WinSCP (no Java/VB/etc.) so I can do a move and rename? Example: I'm downloading files from folder \Project\User and I want to rename the files with <User> as a prefix. So file 100.txt would become BillyB100.txt, file 101.txt becomes BillyB101.txt and so on. I'd like to use a common incoming data folder and eliminate the respective user folders (see below).

Or if the only way to do this is with Java, can anyone provide some sample code? I don't know what exactly can be loaded (or how long it would take to clear) because it is a secured computer.

The script text I have is a long one - each folder is represented - so I won't post the whole thing here. Currently, I am doing a get and then handling the rename on the PC side.

Command line: "c:\program files\WinSCP\" /script=C:\MyScript.txt /log=C:\SCPTest\MyLog.txt

Contents of MyScript:

# Automatically abort script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# Connect
# Force binary mode transfer
option transfer binary
# Change remote directory and Download files
get /Distribution/Project/BillyB/*.* C:\IncomingData\BillyB\
get /Distribution/Project/BillyC/*.* C:\IncomingData\BillyC\
get /Distribution/Project/BobbyA/*.* C:\IncomingData\BobbyA\
get /Distribution/Project/BobbyB/*.* C:\IncomingData\bobbyB\
get /Distribution/Project/JackieA/*.* C:\IncomingData\JackieA\
get /Distribution/Project/JackieB/*.* C:\IncomingData\JackieB\
get /Distribution/Project/Warren/*.* C:\IncomingData\Warren\
get /Distribution/Project/Zeke/*.* C:\IncomingData\Zeke\
# Disconnect
# Exit WinSCP

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
You cannot do with without some programming.
These articles may give you some idea:
Martin Prikryl

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License