vodyanoi
asked on
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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.
Here is a the all procedure:
E:\TMP\FTP>ftp example.com
Connected to example.com
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 (example.com:(none)): billgates@example.com
331 User billgates@example.com OK. Password required
Password:
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
ftp>