对比两个文件夹中的文件删除差集2

import os

import sys

if len(sys.argv) < 3:

print('usage: python trans_pic.py <src_path> <dest_path')

sys.exit(1)

srcPath = sys.argv[1]

destPath = sys.argv[2]

src_name = os.listdir(srcPath)

dest_name = os.listdir(destPath)

for temp in dest_name:

if temp not in src_name:

target = os.path.join(destPath, temp)

os.remove(target)

猜你喜欢

转载自blog.csdn.net/sunfellow2009/article/details/81233598