Remove file extension after successful ftp transfer

requirement: To remove file extension from remote file after succesful automated ftp transfer.

The file is of the form WDC0001.tmp and needs to be changed to WDC0001 on completion of the file transfer.  This is a requierment of the client as they scan the destination folder and process files constantly.  For this reason they do not allow transfer of files without a temporary file extension.

The issue is the number 0001 is a random number and varies for every file that has to be transfered.

The process needs to be automated as the client requires delivery at around 2.30am every day.
We have no issue sending the file. It will be the only file in the source and destination folders. So we can use mput *.tmp to send the file

The difficulty we have is how to remove the file extension from the remote file once it has been delivered.

The machine we are using to send the files is running windows server 2008

So we have access to powershell if needed for scripting.  The server also has a copy of WSFTP_Pro 12 installed if that is of any use.

Does anyone have a suggestion as to how we can achieve this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Here is a the all procedure:

Connected to
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 16 of 1000 allowed.
220-Local time is now 09:30. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
User (
331 User OK. Password required
230-OK. Current restricted directory is /
230 1015327 Kbytes used (99%) - authorized: 1024000 Kb
ftp> cd wd
250 OK. Current directory is /wd
ftp> put WDC0001.tmp
200 PORT command successful
150 Connecting to port 1790
226-1015432 Kbytes used (99%) - authorized: 1024000 Kb
226-File successfully transferred
226 2.530 seconds (measured here), 41.60 Kbytes per second
ftp: 107945 bytes sent in 1,66Seconds 65,18Kbytes/sec.
ftp> rename WDC0001.tmp WDC0001
350 RNFR accepted - file exists, ready for destination
250 File successfully renamed or moved


The file  WDC0001.tmp is on my comuter in folder E:\TMP\FTP.
Then I go to Start-Run and write a CMD and click OK.

Now, it is important to go to the E:\TMP\FTP and press dir *.tmp see your WDC0001.tmp dfile.

The problem is knowing if the download was successful or not and only the client knows that for sure so the client should be the one renaming the files.

If the client has Robo-FTP then they could install the following script as a Windows Service and have it always run and monitor the server.  It will automatically download WDC*.tmp files as they appear on the server and only rename them if the download was a success.

WORKINGDIR "c:\local\download\destination\folder"
FTPLOGON "" /user="vodyanoi" /pw="secret"

GETSITEFILE "WDC*.tmp" /timeout=0
IFERROR GOTO error_reset
SET file_name = %sitefile 
SETRIGHT ext = file_name 4 /split 
RCVFILE %sitefile /as file_name
IFERROR GOTO error_reset
FTPRENAME %sitefile file_name
GOTO loop

PAUSE /for=60
GOTO top

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vodyanoiAuthor Commented:
Persuaded the client to work this way.

Tested and it works like a dream.  They just had to get a copy of  Robo-ftp

Many thanks
whoops, that script has a bug ... that last line should say GOTO connect instead.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.