带有通配符的python中的Filemanager

时间:2018-11-26 08:29:26

标签: python-3.x path wildcard glob

我正在编写脚本来扫描网络文件夹,并将其中的文件(PDF)复制到另一个网络文件夹。 pdf名称以数字开头,并且该数字也在目标名称中

这是我的代码:

import os, shutil, glob
from os import listdir
from os.path import isfile, join files = [f for f in listdir(os.path.join('\\\\fatboy.leleu.be','iedereen','Glenn','Insite')) if isfile(join('\\\\fatboy.leleu.be','iedereen','Glenn','Insite', f))]
dst = glob.glob(os.path.join('\\\\fatboy.leleu.be','iedereen','Glenn','Workflow','2125967_*','PDF Druk'))
for x in files:
    #orderNumber = (x[:7]) <-- get's the 7 numbers
    #client = glob.glob('orderNumber_*') <-- this returns an empty list but should return me the number + name of the client

    path = os.path.join('\\\\fatboy.leleu.be','iedereen','Glenn','Insite', '')
    moveto = os.path.join('\\\\fatboy.leleu.be','iedereen','Glenn','Workflow','2125967_klant_1','PDF Druk')
    files = os.listdir(path)
    files.sort()
    for f in files:
        src = path+f
        dst = moveto
        shutil.move(src,dst)
        print('Succesfully moved', f, 'to', moveto)

我试图将数字后的名称设为通配符,但是glob.glob返回一个列表,并给出path.join的错误

有人给我一些提示吗?

0 个答案:

没有答案