我正在设置一个脚本来根据文件名中包含的文本合并 PDF。我这里的问题是“Violin I”也包含在“Violin II”中,“Alto Saxophone I”也包含在“Alto Saxophone II”中。我该如何设置,所以 tempList 将只包含来自“Violin I”的条目并排除“Violin II”,反之亦然?
pdfList = ["01 Violin I.pdf", "02 Violin I.pdf","01 Violin II.pdf", "02 Violin II.pdf", ]
instruments = ["Soprano", "Tenor", "Violin I", "Violin II", "Viola", "Cello", "Contrabass", "Alto Saxophone I", "Alto Saxophone II", "Tenor Saxophone", "Baritone Saxophone"]
# create arrays for each instrument that can be used for merging/organization
def organizer():
for fileName in pdfList:
for instrument in instruments:
tempList = []
if instrument in fileName:
tempList.append(fileName)
print tempList
print pdfList
organizer()