1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import os, sys, stat
import ftplib
from ftplib import FTP
# Connect FTP Server
def ftpPush(src, filename, dst):
ftp = FTP('xx.xx.xx.xx', user='xxxx', passwd='xxxx')
ftp.cwd(dst)
ftp.storlines("STOR "+filename, open(src+filename, 'rb'))
ftp.quit()
filename = "test" # File Name
src = '/Users/xxxxxxxx/' # path Local
dst ='/xxxxxxxxxxxxxx/' #path chemain FTP server
for fileName in os.listdir(src):
ftpPush(src, filename, dst)
# rename File
name = "test001"
for filename in os.listdir(dst):
os.rename(filename, name) |
Partager