python copy 文件,图片等..

Posted qukaige

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python copy 文件,图片等..相关的知识,希望对你有一定的参考价值。

import shutil
import os
# files = os.listdir(‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/693-693‘)
# base_path = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/693-693/‘
# --------------------
# 获取文件名称
files = os.listdir(‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720‘)
base_path = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720/‘

file_names = files[:-1]
prefix14 = ‘14HP_‘
prefix18 = ‘18HP_‘
to_path14 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/693-693-14/‘
to_path18 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/693-693-18/‘
# -----------------------------------------------------
prefix01 = ‘01HP_‘
prefix02 = ‘02HP_‘
prefix17 = ‘17HP_‘
prefix18 = ‘18HP_‘
prefix19 = ‘19HP_‘
to_path01 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720-01/‘
to_path02 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720-02/‘
to_path17 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720-17/‘
to_path18 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720-18/‘
to_path19 = ‘C:/Users/kaige/Desktop/四元玉鉴/FORGED-full - 副本/720-720-19/‘
def cp666(names, oldpath, newpath):
    for name in names:
        # 从哪 --- > 复制到哪
        shutil.copyfile(oldpath + name, newpath + name)
# cp 14
# cp666(file_names, base_path, to_path14 + prefix14)
# cp 18
# cp666(file_names, base_path, to_path18 + prefix18)
# ----------------------------- sp -----------------------
# cp 01
cp666(file_names, base_path, to_path01 + prefix01)
# cp 02
cp666(file_names, base_path, to_path02 + prefix02)
# cp 17
cp666(file_names, base_path, to_path17 + prefix17)
# cp 18
cp666(file_names, base_path, to_path18 + prefix18)
# cp 19
cp666(file_names, base_path, to_path19 + prefix19)
print(‘ok‘)

  

以上是关于python copy 文件,图片等..的主要内容,如果未能解决你的问题,请参考以下文章

[软件推荐]快速文件复制工具(Limit Copy) V4.0 绿色版

python网页爬虫浅析

python常用代码片段总结

我在哪里更改此 Python 代码片段以将临时文件保存在 tmp 文件夹中?

13 个非常有用的 Python 代码片段

常用python日期日志获取内容循环的代码片段