Move shape file using Python shutil

المشرف العام

Administrator
طاقم الإدارة
So I'm attempting to iterate through several shape files within a folder and only move some of them to a new folder. I'm doing this based on contents of the DBF file where I'm using dbfread to determine whether is should be moved or not. I have this all working as expected except it's only moving the DBF file and not the .shp, .shx, and .prj. files since the logic is only on the DBF. One way I was thinking I could move all files would be to add the basename of the ones I want to move to a List but I seem to be failing at that. Here is the code I'm using. Any help or direction would be appreciated.

from dbfread import DBFMoveFolder_path = r"C:\Data\Move"move_list = []for file in directory_list: if file.split('.')[1] == 'dbf': file_basename = file.split('.')[0] table = DBF(file, load=True) if table.records[0]['name'] == None: move_list.append(file_basename)for movefile in move_list: for file in directory_list: file_basename = file.split('.')[0] if file_basename == movefile: shutil.move(file, MoveFolder_path)

أكثر...
 
أعلى