Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xml.etree.ElementTree as ET
- import os
- from shutil import copyfile
- # Bu dvd'de fscommand klasöründeki ZZZY0258.pdf dosyası aslında bu dvdnin haritası.
- # arsiv.xml olarak script ile aynı yere kopyaladım
- root = ET.parse('arsiv.xml').getroot()
- base = os.path.abspath(os.path.dirname(__file__))
- unknown_files = []
- for type_tag in root.findall('Item'):
- year = type_tag.get('Year')
- print(year)
- os.makedirs(year)
- os.chdir(year)
- for year_tag in type_tag.findall('Item'):
- month = year_tag.get('Month')
- print(month)
- os.makedirs(month)
- os.chdir(month)
- used_articles = []
- for index,article_tag in enumerate(year_tag.findall('Item')):
- title = article_tag.get('Title')
- file_name = article_tag.get('File')
- btd_location = 'fscommand klasorune giden yol'
- print(str(index+1) + '-' + title)
- title = title.replace('/','').replace('(','').replace(')','')
- try:
- if file_name not in used_articles:
- copyfile(btd_location+file_name+'.pdf',str(index+1)+'-'+title+'.pdf')
- used_articles.append(file_name)
- except FileNotFoundError as err:
- print(err)
- unknown_files.append(file_name)
- os.chdir('../')
- os.chdir(base)
- missing = open('missing.txt','w')
- for m_file in unknown_files:
- missing.write(m_file+'\n')
- missing.close()
- print(unknown_files)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement