#-*- coding:utf-8 -*-
#修改ftp服务器上的文件名
from ftplib import FTP
def ftpoperate(ip,port,username,passwd,path):
#获取ftp服务器某一文件夹下的所有文件名
ftp = FTP()
ftp.set_debuglevel(0)
ftp.connect(ip,port)
ftp.login(username,passwd)
ftp.cwd(path)
L = ftp.nlst()
nlist = []
for index,item in enumerate(L):
ftp.rename(item,item.replace(".mp4","_sc99_01.mp4"))
nlist.append(item)
ftp.close()
return L
filename = ftpoperate("IP","21","用户名","mima","/2018年1月短视频")
print len(filename)
for item in filename:
print item
#修改ftp服务器上的文件名
from ftplib import FTP
def ftpoperate(ip,port,username,passwd,path):
#获取ftp服务器某一文件夹下的所有文件名
ftp = FTP()
ftp.set_debuglevel(0)
ftp.connect(ip,port)
ftp.login(username,passwd)
ftp.cwd(path)
L = ftp.nlst()
nlist = []
for index,item in enumerate(L):
ftp.rename(item,item.replace(".mp4","_sc99_01.mp4"))
nlist.append(item)
ftp.close()
return L
filename = ftpoperate("IP","21","用户名","mima","/2018年1月短视频")
print len(filename)
for item in filename:
print item