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

martin

Re: Can I Move Files on FTP Host Server?

Use mv *.csv /downloads/MySQL/downloaded/* in the WinSCP script file (dailyimport.txt).
SalientAnimal

Can I Move Files on FTP Host Server?

Hi All,

I've started setting up the automation of picking up files off of the FTP Host, and all of this is working as intended thus far.

The next step I need to achieve, and I'm not sure if its possible or not is to move the source file on the FTP Host to another directory on that FTP host once it has been copied without changing the name of the file on the host server.

The script I am currently using, does not seem to work. Some guidance please?

@echo off

winscp.com /script=dailyimport.txt

if %ERRORLEVEL% neq 0 goto error
 
echo Download succeeded, moving local files
move *.csv /downloads/MySQL/downloaded
exit /b 0
 
:error
echo Upload failed, keeping local files
exit /b 1


My dailyimport.txt looks like this:

# Connect

open ftp:details
# Change remote directory
cd /downloads/MySQL
# Force binary mode transfer
option transfer binary
# Download file to the local directory
get filename001_*.csv "E:\Data\DailyImports\newfilename001.csv"
get filename002_*.csv "E:\Data\DailyImports\newfilename002.csv"
get filename003_*.csv "E:\Data\DailyImports\newfilename003.csv"

mv *.csv cd /downloads/MySQL/downloads/*.csv
# Disconnect
close
# Exit WinSCP
exit