# 将original_path的东西移动到destination_path下
import os
import shutil
def mycopyfile(srcfile, dstpath): # 复制函数
if not os.path.isfile(srcfile):
print("%s not exist!" % (srcfile))
else:
fpath, fname = os.path.split(srcfile) # 分离文件名和路径
if not os.path.exists(dstpath):
os.makedirs(dstpath) # 创建路径
shutil.copy(srcfile, dstpath) # 复制文件
print("copy %s -> %s" % (srcfile, dstpath))
original_path = 'C:/Users/A11220321050141/Desktop/data'
destination_path = 'C:/Users/A11220321050141/Desktop/data_new'
files = os.listdir(original_path)
for f in files:
file = original_path + '/' + f
mycopyfile(file, destination_path)
python 移动文件位置
猜你喜欢
转载自blog.csdn.net/Qingyou__/article/details/124430034
今日推荐
周排行