{"id":346308,"date":"2023-03-06T03:00:23","date_gmt":"2023-03-06T03:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346308"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346308","title":{"rendered":"<span>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 doc \u0438 docx \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0438! \u041f\u0440\u043e\u0448\u0443 \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 doc \u0438 docx \u0444\u0430\u0439\u043b\u0430\u0445 \u0441 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0435\u0439 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0435\u0441 \u044d\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0421\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0441\u0448\u0430\u0440\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 (\u0434\u0430, \u0434\u0430, \u043e\u0431\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 \u044d\u0442\u043e \u0437\u043b\u043e, \u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u0442\u043e \u0432\u043d\u0435\u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/p>\n<p>\u0421\u0430\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 watchdog (pip install watchdog).<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\"># \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler  # \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f class Watcher:     def __init__(self, path):         self.observer = Observer()         self.path = path      def run(self):         event_handler = Handler()         self.observer.schedule(event_handler, self.path, recursive=True)         self.observer.start()         try:             while True:                 time.sleep(1)         except:             self.observer.stop()             print(\"Error\")          self.observer.join()   class Handler(FileSystemEventHandler):     @staticmethod     def on_any_event(event):         if event.is_directory:             return None         print(             \"[{}] noticed: [{}] on: [{}] \".format(                 time.asctime(), event.event_type, event.src_path             )         )           if __name__ == \"__main__\":     w = Watcher('C:\\\\Users\\\\user\\\\Desktop\\\\')     w.run()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 (\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043a\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b) \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u0442\u043e\u043b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0430\u043f\u043a\u0443 &#171;C:\\Users\\user\\Desktop\\&#187; \u044d\u0442\u0443 \u0443\u043a\u0430\u0437\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<p>[Mon Dec 5 14:32:37 2022] noticed: [modified] on: [C:\\Users\\user\\Desktop\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 Microsoft Word.docx]<\/p>\n<p>\u0422\u0443\u0442 \u043d\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0444\u0430\u0439\u043b. \u042d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e docx \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 doc \u0438 docx \u0444\u0430\u0439\u043b\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\"># -*- coding: utf-8 -*-  # \u0414\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0444\u0430\u0439\u043b\u0430 import docx # \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler  # \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f class Watcher:     def __init__(self, path):         self.observer = Observer()         self.path = path      def run(self):         event_handler = Handler()         self.observer.schedule(event_handler, self.path, recursive=True)         self.observer.start()         try:             while True:                 time.sleep(1)         except:             self.observer.stop()             print(\"Error\")          self.observer.join()   class Handler(FileSystemEventHandler):     @staticmethod     def on_any_event(event):         # if event.is_directory:         #     return None         # print(         #     \"[{}] noticed: [{}] on: [{}] \".format(         #         time.asctime(), event.event_type, event.src_path         #     )         # )                  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0444\u0430\u0439\u043b\u0430         if '.tmp' in event.src_path:             return None         try:             document = docx.Document(docx = event.src_path)             core_properties = document.core_properties             print(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}')         except:             pass  if __name__ == \"__main__\":     w = Watcher('C:\\\\Users\\\\user\\\\Desktop\\\\')     w.run()<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p><strong>print(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}&#8217;)<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<p>\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447 \u0432 2022-12-05 07:35:00 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b C:\\Users\\user\\Desktop\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 Microsoft Word.docx<\/p>\n<p>\u0414\u043b\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"python\">f = open('change-doc.log','w')  # \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 f.write(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}\\n')  # \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b f.close()  # \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043e):  <\/p>\n<pre><code class=\"python\">import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText   fromaddr = \"test@mail.ru\" toaddr = \"test2@mail.ru\" mypass = \"password\"   msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = f'\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0444\u0430\u0439\u043b {event.src_path}'   body = f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}' msg.attach(MIMEText(body, 'plain'))   server = smtplib.SMTP_SSL('smtp.mail.ru', 465) server.login(fromaddr, mypass) text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 docx \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c: <\/p>\n<pre><code class=\"python\">file_name = 'C:\\\\Users\\\\user\\\\Desktop\\\\123.docx'  document = docx.Document(docx = file_name) core_properties = document.core_properties print('author', core_properties.author) print('created', core_properties.created) print('last_modified_by', core_properties.last_modified_by) print('last_printed', core_properties.last_printed) print('modified', core_properties.modified) print('revision', core_properties.revision) print('title', core_properties.title) print('category', core_properties.category) print('comments', core_properties.comments) print('identifier', core_properties.identifier) print('keywords', core_properties.keywords) print('language', core_properties.language) print('subject', core_properties.subject) print('version', core_properties.version) print('keywords', core_properties.keywords) print('content_status', core_properties.content_status)<\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!!!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/720600\/\"> https:\/\/habr.com\/ru\/post\/720600\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0438! \u041f\u0440\u043e\u0448\u0443 \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 doc \u0438 docx \u0444\u0430\u0439\u043b\u0430\u0445 \u0441 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0435\u0439 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0435\u0441 \u044d\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0421\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0441\u0448\u0430\u0440\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 (\u0434\u0430, \u0434\u0430, \u043e\u0431\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 \u044d\u0442\u043e \u0437\u043b\u043e, \u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c) \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u0442\u043e \u0432\u043d\u0435\u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/p>\n<p>\u0421\u0430\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 watchdog (pip install watchdog).<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\"># \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler  # \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f class Watcher:     def __init__(self, path):         self.observer = Observer()         self.path = path      def run(self):         event_handler = Handler()         self.observer.schedule(event_handler, self.path, recursive=True)         self.observer.start()         try:             while True:                 time.sleep(1)         except:             self.observer.stop()             print(\"Error\")          self.observer.join()   class Handler(FileSystemEventHandler):     @staticmethod     def on_any_event(event):         if event.is_directory:             return None         print(             \"[{}] noticed: [{}] on: [{}] \".format(                 time.asctime(), event.event_type, event.src_path             )         )           if __name__ == \"__main__\":     w = Watcher('C:\\\\Users\\\\user\\\\Desktop\\\\')     w.run()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 (\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043a\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b) \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u0441\u0442\u043e\u043b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0430\u043f\u043a\u0443 &#171;C:\\Users\\user\\Desktop\\&#187; \u044d\u0442\u0443 \u0443\u043a\u0430\u0437\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<p>[Mon Dec 5 14:32:37 2022] noticed: [modified] on: [C:\\Users\\user\\Desktop\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 Microsoft Word.docx]<\/p>\n<p>\u0422\u0443\u0442 \u043d\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0444\u0430\u0439\u043b. \u042d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e docx \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 doc \u0438 docx \u0444\u0430\u0439\u043b\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\"># -*- coding: utf-8 -*-  # \u0414\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0444\u0430\u0439\u043b\u0430 import docx # \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler  # \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f class Watcher:     def __init__(self, path):         self.observer = Observer()         self.path = path      def run(self):         event_handler = Handler()         self.observer.schedule(event_handler, self.path, recursive=True)         self.observer.start()         try:             while True:                 time.sleep(1)         except:             self.observer.stop()             print(\"Error\")          self.observer.join()   class Handler(FileSystemEventHandler):     @staticmethod     def on_any_event(event):         # if event.is_directory:         #     return None         # print(         #     \"[{}] noticed: [{}] on: [{}] \".format(         #         time.asctime(), event.event_type, event.src_path         #     )         # )                  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0444\u0430\u0439\u043b\u0430         if '.tmp' in event.src_path:             return None         try:             document = docx.Document(docx = event.src_path)             core_properties = document.core_properties             print(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}')         except:             pass  if __name__ == \"__main__\":     w = Watcher('C:\\\\Users\\\\user\\\\Desktop\\\\')     w.run()<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p><strong>print(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}&#8217;)<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<p>\u0418\u0432\u0430\u043d\u043e\u0432 \u0418\u0432\u0430\u043d \u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447 \u0432 2022-12-05 07:35:00 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b C:\\Users\\user\\Desktop\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 Microsoft Word.docx<\/p>\n<p>\u0414\u043b\u044f \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"python\">f = open('change-doc.log','w')  # \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 f.write(f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}\\n')  # \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b f.close()  # \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043e):  <\/p>\n<pre><code class=\"python\">import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText   fromaddr = \"test@mail.ru\" toaddr = \"test2@mail.ru\" mypass = \"password\"   msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = f'\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0444\u0430\u0439\u043b {event.src_path}'   body = f'{core_properties.last_modified_by} \u0432 {core_properties.modified} \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u0430\u0439\u043b {event.src_path}' msg.attach(MIMEText(body, 'plain'))   server = smtplib.SMTP_SSL('smtp.mail.ru', 465) server.login(fromaddr, mypass) text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit()<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 docx \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c: <\/p>\n<pre><code class=\"python\">file_name = 'C:\\\\Users\\\\user\\\\Desktop\\\\123.docx'  document = docx.Document(docx = file_name) core_properties = document.core_properties print('author', core_properties.author) print('created', core_properties.created) print('last_modified_by', core_properties.last_modified_by) print('last_printed', core_properties.last_printed) print('modified', core_properties.modified) print('revision', core_properties.revision) print('title', core_properties.title) print('category', core_properties.category) print('comments', core_properties.comments) print('identifier', core_properties.identifier) print('keywords', core_properties.keywords) print('language', core_properties.language) print('subject', core_properties.subject) print('version', core_properties.version) print('keywords', core_properties.keywords) print('content_status', core_properties.content_status)<\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!!!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/720600\/\"> https:\/\/habr.com\/ru\/post\/720600\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346308","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346308"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346308\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}