Wednesday, May 16, 2007

FTP a file and rename it to today's date.

This isn't difficult, but it can be useful. This routine will grab a file (one or more actually but be careful) and rename the received file to today's date. You could go further and exercise the %TIME% variable, but that's up to you.

getfile.cmd:
@echo off
if exist dlfilespec del /f /q dlfilespec
ftp -s:getfile.ftp -v
if exist destfilespec_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%.zip ~SPLIT~
del /f /q destfilespec_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%.zip
ren dlfilespec ~SPLIT~
destfilespec_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%.zip
getfile.ftp:
open host
username
password
binary
prompt
mget dlfilespec
ls
close
bye

No comments:

There is no individual ownership when you are part of a team, it's the sum of the parts that makes you the RESILIENT team you need to be.