Wrote this script to send a zip file that gets created every day and sent to a FTP server. In line 16, getting a windows 183 error cannot create file that already exists. I am using os.rename, and it works if I run it stand alone. Any ideas?

import ftplib
import os
import sys
import traceback
import datetime

today = datetime.date.today()
host='mail.freshfoodconcepts.com'
port='21'
login='ftpclient'
password='74Dog91'
some_directory='Warwick'
fullname='C:\\crunchtime'
rb='crunsend.zip'

os.rename("c:\\crunchtime\\crunsend.zip", "c:\\kmfc\\crunchtime" + today.strftime("%m%d%y") + ".zip")


print "Files:", 'c:\\crunchtime\\crunsend.zip'

print "Logging in..."
ftp = ftplib.FTP()
ftp.connect(host, port)
print ftp.getwelcome()
try:
    try:
        ftp.login(login, password)
        ftp.cwd(some_directory)
        # move to the desired upload directory
        print "Currently in:", ftp.pwd()

        print "Uploading...",
        fullname = 'c:\\crunchtime\\crunsend' + today.strftime("%m%d%y") + '.zip'
        name = os.path.split(fullname)[1]
        f = open(fullname, "rb")
        ftp.storbinary('STOR ' + name, f)
        f.close()
        print "OK"
        
        print "Files:"
        print ftp.retrlines('LIST')
    finally:
        print "Quitting..."
        ftp.quit()
except:
    traceback.print_exc()

Sorry for the dumb question, I saw the problem, thanks for looking though.

commented: There's not dumb questions, just dumb answers. +9

Sorry for the dumb question, I saw the problem, thanks for looking though.

They are pretty much all dumb.....after you find the answer. Also, please mark the post solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.