דילוג לתוכן
  • חוקי הפורום
  • פופולרי
  • לא נפתר
  • משתמשים
  • חיפוש גוגל בפורום
  • צור קשר
עיצובים
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • ברירת מחדל (ללא עיצוב (ברירת מחדל))
  • ללא עיצוב (ברירת מחדל)
כיווץ
מתמחים טופ
  1. דף הבית
  2. קטגוריות בהרצה
  3. תכנות
  4. Python
  5. עזרה הדדית - Python
  6. בקשת עזרה תוכנה למיון ספרים!

בקשת עזרה תוכנה למיון ספרים!

מתוזמן נעוץ נעול הועבר עזרה הדדית - Python
38 פוסטים 7 כותבים 1.6k צפיות 7 עוקבים
  • מהישן לחדש
  • מהחדש לישן
  • הכי הרבה הצבעות
תגובה
  • תגובה כנושא
התחברו כדי לפרסם תגובה
נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
  • א אלף שין

    שלום רב
    לאחר עבודה הנני שמח לבשר על תחילתו של סקריפט למיון ספרים במחשב,
    המטרה היא שמי שהוריד הרבה ספרים מהיברו-בוקס יוכל למיין אותם בקלות ואוטומטית לתיקייה ייעודית,

    לכן כתבתי בס"ד סקריפט שבודק אם בעמוד הראשון או השני בקובץ מופיע W [הקישור לאתר שלהם]
    ואם אכן מוצא תו זה הוא מעביר מיד את הקובץ לתיקייה שנבחרה,
    להלן הסקריפט:

    import os
    import tkinter as tk
    from tkinter import filedialog
    import PyPDF2
    import re
    import shutil
    import threading
    from queue import Queue
    from pdfminer.high_level import extract_pages
    from pdfminer.layout import LAParams, LTTextBox, LTTextContainer
    
    class PDF_Sorter:
        def __init__(self, root):
            self.root = root
            self.root.title("PDF Sorter")
            self.create_gui()
    
        def create_gui(self):
            self.source_folder = tk.StringVar()
            self.dest_folder = tk.StringVar()
    
            frame = tk.Frame(self.root)
            frame.pack(fill="both", expand=True)
    
            tk.Label(frame, text="Source Folder:").pack()
            self.source_folder_entry = tk.Entry(frame, textvariable=self.source_folder, width=50)
            self.source_folder_entry.pack()
    
            tk.Button(frame, text="Browse", command=self.browse_source_folder).pack(side=tk.LEFT, padx=5, pady=5)
    
            tk.Label(frame, text="Destination Folder:").pack()
            self.dest_folder_entry = tk.Entry(frame, textvariable=self.dest_folder, width=50)
            self.dest_folder_entry.pack()
    
            tk.Button(frame, text="Browse", command=self.browse_dest_folder).pack(side=tk.LEFT, padx=5, pady=5)
    
            tk.Button(frame, text="Start", command=self.sort_pdfs).pack(padx=5, pady=5)
    
        def browse_source_folder(self):
            self.source_folder.set(filedialog.askdirectory())
    
        def browse_dest_folder(self):
            self.dest_folder.set(filedialog.askdirectory())
    
        def sort_pdfs(self):
            self.queue = Queue()
            for root, dirs, files in os.walk(self.source_folder.get()):
                for file in files:
                    if file.endswith('.pdf'):
                        file_path = os.path.join(root, file)
                        self.queue.put((file_path, self.dest_folder.get()))
    
            self.worker_thread = threading.Thread(target=self.process_queued_pdfs)
            self.worker_thread.start()
            self.root.after(1000, self.worker_thread.join)
            print("PDF sorting complete")
    
        def process_queued_pdfs(self):
            while not self.queue.empty():
                file_path, dest_folder = self.queue.get()
                try:
                    with open(file_path, 'rb') as pdf_file:
                        pdf_reader = PyPDF2.PdfReader(pdf_file)
                        for i in range(min(2, len(pdf_reader.pages))):
                            text = pdf_reader.pages[i].extract_text()
                            if re.search(r'w|W', text, re.IGNORECASE) or re.search(r'\\\[]', text):
                                shutil.copy(file_path, os.path.join(dest_folder, os.path.basename(file_path)))
                                break
                except Exception as e:
                    print(f"Error processing {file_path}: {e}")
    
    if __name__ == "__main__":
        root = tk.Tk()
        pdf_sorter = PDF_Sorter(root)
        root.mainloop()
    

    הבעיה היא שכ50% מהספרים של היברו בוקס,
    הסימן מים שלהם מופיע לא כמלל רגיל, אלא כמלל בתוך תיבת טקסט,
    164be501-36ac-4c06-ac80-266de3d3fc99-image.png
    ולא הצלחתי עד כה למצוא ספרייה שתצליח לזהות את המלל,
    לכן אני מבקש עזרה מכל המומחים פה מי שיכול לעזור תע"ב,
    נ"ב: אפשר גם לעשות סקריפט שרק יזהה אם קיים תיבת טקסט, ואם כן יעביר,
    לא משנה מה כתוב בה, כי רק בספרים שלהם יש תיבת טקסט בעמוד הראשון....

    @אביי @האדם-החושב @תכנות

    עריכה:
    בפוסט האחרון עדכנתי את הסקריפט, מי שרוצה יכול לדלג לשם,
    הוא ממין בצורה יסודית,
    רק אני מבקש עזרה ממי שיכול לקמפל אתו.

    yzahnY מנותק
    yzahnY מנותק
    yzahn
    עימוד
    כתב נערך לאחרונה על ידי yzahn
    #21

    @אלף-שין

    from pypdf import PdfReader
    
    def is_hebrew_books(file):
        reader = PdfReader(file)
        annotations = reader.pages[0].annotations
        for annotation in annotations:
            if annotation.get("/Subtype") == "/Link" and annotation.get("/A").get("/URI") == "http://www.hebrewbooks.org":
                return True
        return False
    

    נ.ב. בדקתי רק על שני קבצים

    📧 | יוסי@יצ.קום

    א תגובה 1 תגובה אחרונה
    2
    • yzahnY yzahn

      @אלף-שין

      from pypdf import PdfReader
      
      def is_hebrew_books(file):
          reader = PdfReader(file)
          annotations = reader.pages[0].annotations
          for annotation in annotations:
              if annotation.get("/Subtype") == "/Link" and annotation.get("/A").get("/URI") == "http://www.hebrewbooks.org":
                  return True
          return False
      

      נ.ב. בדקתי רק על שני קבצים

      א מנותק
      א מנותק
      אלף שין
      כתב נערך לאחרונה על ידי אלף שין
      #22

      @yzahn
      כנראה התכוונת לזה:

      from PyPDF2 import PdfReader
      
      def is_hebrew_books(file):
          reader = PdfReader(file)
          try:
              annotations = reader.getOutlines()
          except:
              return False
      
          for item in annotations:
              if isinstance(item, dict):
                  if item.get('/URI', '').startswith('http://www.hebrewbooks.org'):
                      return True
      
          return False
      
      # Example usage:
      file_path = 'path_to_your_file.pdf'  # replace with your file path
      result = is_hebrew_books(file_path)
      
      if result:
          print("The PDF is a Hebrew book.")
      else:
          print("The PDF is not a Hebrew book.")
      

      אבל זה לא זיהה לי...
      צריך ספריית PDF מתקדמת יותר...

      yzahnY תגובה 1 תגובה אחרונה
      0
      • א אלף שין

        @yzahn
        כנראה התכוונת לזה:

        from PyPDF2 import PdfReader
        
        def is_hebrew_books(file):
            reader = PdfReader(file)
            try:
                annotations = reader.getOutlines()
            except:
                return False
        
            for item in annotations:
                if isinstance(item, dict):
                    if item.get('/URI', '').startswith('http://www.hebrewbooks.org'):
                        return True
        
            return False
        
        # Example usage:
        file_path = 'path_to_your_file.pdf'  # replace with your file path
        result = is_hebrew_books(file_path)
        
        if result:
            print("The PDF is a Hebrew book.")
        else:
            print("The PDF is not a Hebrew book.")
        

        אבל זה לא זיהה לי...
        צריך ספריית PDF מתקדמת יותר...

        yzahnY מנותק
        yzahnY מנותק
        yzahn
        עימוד
        כתב נערך לאחרונה על ידי yzahn
        #23

        @אלף-שין השתמשתי בגירסה האחרונה של pypdf (בלי 2) זה אוחז כבר ב-4
        לא בדקתי מה המקביל ב-2

        📧 | יוסי@יצ.קום

        א תגובה 1 תגובה אחרונה
        0
        • yzahnY yzahn

          @אלף-שין השתמשתי בגירסה האחרונה של pypdf (בלי 2) זה אוחז כבר ב-4
          לא בדקתי מה המקביל ב-2

          א מנותק
          א מנותק
          אלף שין
          כתב נערך לאחרונה על ידי
          #24

          @yzahn
          אה..
          חבל שלא ידעתי...
          כי לא הבנתי למה יש כל הזמן שגיאות...
          סידרתי רק באדיבות GPT כלשהוא....
          עכ"פ אשמח דווקא לקבל עזרה אבל צריך סקריפט שיסרוק ב3 שלבים:
          1] האם מופיע תו W בעמוד הראשון- אם כן מעביר, אם לא עובר לשלב 2,
          2] האם נמצא בעמוד הראשון תיבת טקסט [אם כן בטוח יש בתוכה W] אם כן מעביר, אם לא עובר לשלב 3,
          3] מעביר את העמוד הראשון OCR, ובודק שוב האם נמצא תו W.

          yzahnY 2 תגובות תגובה אחרונה
          0
          • א אלף שין

            @yzahn
            אה..
            חבל שלא ידעתי...
            כי לא הבנתי למה יש כל הזמן שגיאות...
            סידרתי רק באדיבות GPT כלשהוא....
            עכ"פ אשמח דווקא לקבל עזרה אבל צריך סקריפט שיסרוק ב3 שלבים:
            1] האם מופיע תו W בעמוד הראשון- אם כן מעביר, אם לא עובר לשלב 2,
            2] האם נמצא בעמוד הראשון תיבת טקסט [אם כן בטוח יש בתוכה W] אם כן מעביר, אם לא עובר לשלב 3,
            3] מעביר את העמוד הראשון OCR, ובודק שוב האם נמצא תו W.

            yzahnY מנותק
            yzahnY מנותק
            yzahn
            עימוד
            כתב נערך לאחרונה על ידי yzahn
            #25

            @אלף-שין כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

            אבל צריך סקריפט שיסרוק ב3 שלבים

            למה החלטת ככה? מה לא טוב עם הפונקציה שלי? (תביא דוגמאות של קבצים שזה לא עובד עליהם ואנסה לתקן)

            האם נמצא בעמוד הראשון תיבת טקסט

            תוכל להגדיר בשפה יותר טכנית/מדוייקת מה זה תיבת טקסט? כי המושג "תיבת טקסט" לא קיים ב-PDF

            📧 | יוסי@יצ.קום

            א תגובה 1 תגובה אחרונה
            0
            • א אלף שין

              @yzahn
              אה..
              חבל שלא ידעתי...
              כי לא הבנתי למה יש כל הזמן שגיאות...
              סידרתי רק באדיבות GPT כלשהוא....
              עכ"פ אשמח דווקא לקבל עזרה אבל צריך סקריפט שיסרוק ב3 שלבים:
              1] האם מופיע תו W בעמוד הראשון- אם כן מעביר, אם לא עובר לשלב 2,
              2] האם נמצא בעמוד הראשון תיבת טקסט [אם כן בטוח יש בתוכה W] אם כן מעביר, אם לא עובר לשלב 3,
              3] מעביר את העמוד הראשון OCR, ובודק שוב האם נמצא תו W.

              yzahnY מנותק
              yzahnY מנותק
              yzahn
              עימוד
              כתב נערך לאחרונה על ידי
              #26

              @אלף-שין כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

              באדיבות GPT כלשהוא

              הוא טעה בגדול, אין קשר בין הקוד שהוא פלט לקוד שלי
              הנה התיקון עבור PyPDF2

              from PyPDF2 import PdfReader
              
              def is_hebrew_books(file):
                  reader = PdfReader(file)
                  annotations = reader.pages[0].annotations
                  for annotation in annotations:
                      if annotation.get_object().get("/Subtype") == "/Link" and annotation.get_object().get("/A").get("/URI") == "http://www.hebrewbooks.org":
                          return True
                  return False
              

              📧 | יוסי@יצ.קום

              תגובה 1 תגובה אחרונה
              1
              • yzahnY yzahn

                @אלף-שין כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                אבל צריך סקריפט שיסרוק ב3 שלבים

                למה החלטת ככה? מה לא טוב עם הפונקציה שלי? (תביא דוגמאות של קבצים שזה לא עובד עליהם ואנסה לתקן)

                האם נמצא בעמוד הראשון תיבת טקסט

                תוכל להגדיר בשפה יותר טכנית/מדוייקת מה זה תיבת טקסט? כי המושג "תיבת טקסט" לא קיים ב-PDF

                א מנותק
                א מנותק
                אלף שין
                כתב נערך לאחרונה על ידי אלף שין
                #27

                @yzahn כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                למה החלטת ככה? מה לא טוב עם הפונקציה שלי? (תביא דוגמאות של קבצים שזה לא עובד עליהם ואנסה לתקן)

                האם נמצא בעמוד הראשון תיבת טקסט

                תוכל להגדיר בשפה יותר טכנית/מדוייקת מה זה תיבת טקסט? כי המושג "תיבת טקסט" לא קיים ב-PDF

                העליתי כאן עמוד ראשון מ3 ספרים,
                שים לב להבדל:
                בספר חידושי חתם סופר: הטקסט מופיע בתוך "תיבת טקסט".
                בספר בן יהוידע ח"א: מופיע כמלל רגיל בדומה לשאר המלל בעמוד.
                בספר בן יהוידע ח"ב: צריך עדיין לעבור OCR.

                חדושי חתם סופר - ע''ז_1.pdf
                בן יהוידע ח''א_1.pdf
                בן יהוידע ח''ב_1.pdf

                לכן אני רוצה סקריפט חכם שיבדוק אם מוצא את האות W , כי אולי זה סוג 1 או 2, וחבל סתם לעשות עוד פעם זיהוי תווים,
                ורק אם לא מצא שאז יכול להיות שהסיבה היא כי זה סוג 3 אז ליתר ביטחון יחפש שוב לאחר שיעשה OCR לעמוד הראשון.

                @אביי אני מחכה רק לך....

                yzahnY יום חדש מתחילי 2 תגובות תגובה אחרונה
                1
                • א אלף שין

                  @yzahn כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                  למה החלטת ככה? מה לא טוב עם הפונקציה שלי? (תביא דוגמאות של קבצים שזה לא עובד עליהם ואנסה לתקן)

                  האם נמצא בעמוד הראשון תיבת טקסט

                  תוכל להגדיר בשפה יותר טכנית/מדוייקת מה זה תיבת טקסט? כי המושג "תיבת טקסט" לא קיים ב-PDF

                  העליתי כאן עמוד ראשון מ3 ספרים,
                  שים לב להבדל:
                  בספר חידושי חתם סופר: הטקסט מופיע בתוך "תיבת טקסט".
                  בספר בן יהוידע ח"א: מופיע כמלל רגיל בדומה לשאר המלל בעמוד.
                  בספר בן יהוידע ח"ב: צריך עדיין לעבור OCR.

                  חדושי חתם סופר - ע''ז_1.pdf
                  בן יהוידע ח''א_1.pdf
                  בן יהוידע ח''ב_1.pdf

                  לכן אני רוצה סקריפט חכם שיבדוק אם מוצא את האות W , כי אולי זה סוג 1 או 2, וחבל סתם לעשות עוד פעם זיהוי תווים,
                  ורק אם לא מצא שאז יכול להיות שהסיבה היא כי זה סוג 3 אז ליתר ביטחון יחפש שוב לאחר שיעשה OCR לעמוד הראשון.

                  @אביי אני מחכה רק לך....

                  yzahnY מנותק
                  yzahnY מנותק
                  yzahn
                  עימוד
                  כתב נערך לאחרונה על ידי yzahn
                  #28

                  @אלף-שין
                  א) במקום pypdf אני משתמש עכשיו ב-pymupdf
                  ב) תתקין במחשב שלך את זה

                  הקוד הבא עובד על שלושת הקבצים שהבאת,
                  אם יש לך עוד דוגמאות של קבצים שזה לא עובד עליהם אנא העלה את הקובץ לפה ונראה מה יש לעשות בנושא

                  הנה הקוד:

                  from pymupdf import pymupdf
                  
                  def is_hebrewbooks_file(file_path):
                    doc = pymupdf.open(file_path)
                    page = doc[0]
                    text = page.get_text()
                    if text.find("hebrewbook") != -1:
                      return True
                    # if failed - try ocr
                    ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                    if ocr_text.find("hebrewbook") != -1:
                      return True
                    return False
                  

                  📧 | יוסי@יצ.קום

                  א 2 תגובות תגובה אחרונה
                  3
                  • א אלף שין

                    @yzahn כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                    למה החלטת ככה? מה לא טוב עם הפונקציה שלי? (תביא דוגמאות של קבצים שזה לא עובד עליהם ואנסה לתקן)

                    האם נמצא בעמוד הראשון תיבת טקסט

                    תוכל להגדיר בשפה יותר טכנית/מדוייקת מה זה תיבת טקסט? כי המושג "תיבת טקסט" לא קיים ב-PDF

                    העליתי כאן עמוד ראשון מ3 ספרים,
                    שים לב להבדל:
                    בספר חידושי חתם סופר: הטקסט מופיע בתוך "תיבת טקסט".
                    בספר בן יהוידע ח"א: מופיע כמלל רגיל בדומה לשאר המלל בעמוד.
                    בספר בן יהוידע ח"ב: צריך עדיין לעבור OCR.

                    חדושי חתם סופר - ע''ז_1.pdf
                    בן יהוידע ח''א_1.pdf
                    בן יהוידע ח''ב_1.pdf

                    לכן אני רוצה סקריפט חכם שיבדוק אם מוצא את האות W , כי אולי זה סוג 1 או 2, וחבל סתם לעשות עוד פעם זיהוי תווים,
                    ורק אם לא מצא שאז יכול להיות שהסיבה היא כי זה סוג 3 אז ליתר ביטחון יחפש שוב לאחר שיעשה OCR לעמוד הראשון.

                    @אביי אני מחכה רק לך....

                    יום חדש מתחילי מנותק
                    יום חדש מתחילי מנותק
                    יום חדש מתחיל
                    כתב נערך לאחרונה על ידי
                    #29

                    @אלף-שין אני מבין שכל הקבצים נמצאים בתיקי' מסוימת, ויש שם גם עוד קבצים ואתה רוצה להפריד ביניהם.
                    אז למה אתה צריך דווקא סקריפט אחד שיעשה את שלשת השלבים הנ"ל, למה לא לעשות זאת בשלשה סקריפטים שונים, שתריץ כל אחד אחרי שהשני יגמור?

                    yzahnY תגובה 1 תגובה אחרונה
                    0
                    • יום חדש מתחילי יום חדש מתחיל

                      @אלף-שין אני מבין שכל הקבצים נמצאים בתיקי' מסוימת, ויש שם גם עוד קבצים ואתה רוצה להפריד ביניהם.
                      אז למה אתה צריך דווקא סקריפט אחד שיעשה את שלשת השלבים הנ"ל, למה לא לעשות זאת בשלשה סקריפטים שונים, שתריץ כל אחד אחרי שהשני יגמור?

                      yzahnY מנותק
                      yzahnY מנותק
                      yzahn
                      עימוד
                      כתב נערך לאחרונה על ידי yzahn
                      #30

                      @יום-חדש-מתחיל מה אתה מנסה להרוויח? כל מה שתעשה בשלושה סקריפטים תוכל לעשות בסקריפט אחד בצורה יותר יעילה

                      📧 | יוסי@יצ.קום

                      יום חדש מתחילי תגובה 1 תגובה אחרונה
                      1
                      • yzahnY yzahn

                        @יום-חדש-מתחיל מה אתה מנסה להרוויח? כל מה שתעשה בשלושה סקריפטים תוכל לעשות בסקריפט אחד בצורה יותר יעילה

                        יום חדש מתחילי מנותק
                        יום חדש מתחילי מנותק
                        יום חדש מתחיל
                        כתב נערך לאחרונה על ידי
                        #31

                        @yzahn כי כפי שאני מבין, את שתי השלבים הראשונים כבר יש לו סקריפט, אז מה הוא צריך שבסקריפט הזה יכתבו גם את השלבים הנ"ל?

                        תגובה 1 תגובה אחרונה
                        1
                        • yzahnY yzahn

                          @אלף-שין
                          א) במקום pypdf אני משתמש עכשיו ב-pymupdf
                          ב) תתקין במחשב שלך את זה

                          הקוד הבא עובד על שלושת הקבצים שהבאת,
                          אם יש לך עוד דוגמאות של קבצים שזה לא עובד עליהם אנא העלה את הקובץ לפה ונראה מה יש לעשות בנושא

                          הנה הקוד:

                          from pymupdf import pymupdf
                          
                          def is_hebrewbooks_file(file_path):
                            doc = pymupdf.open(file_path)
                            page = doc[0]
                            text = page.get_text()
                            if text.find("hebrewbook") != -1:
                              return True
                            # if failed - try ocr
                            ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                            if ocr_text.find("hebrewbook") != -1:
                              return True
                            return False
                          
                          א מנותק
                          א מנותק
                          אלף שין
                          כתב נערך לאחרונה על ידי
                          #32

                          @yzahn
                          מדהים הסקריפט שלך פשוט עובד נפלא!!
                          תודה רבה!!

                          from pymupdf import pymupdf
                          
                          def is_hebrewbooks_file(file_path):
                            doc = pymupdf.open(file_path)
                            page = doc[0]
                            text = page.get_text()
                            if text.find("hebrewbook") != -1:
                              return True
                            ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                            if ocr_text.find("hebrewbook") != -1:
                              return True
                            return False
                          
                          file_path = "40809.pdf"  # replace with your file path
                          result = is_hebrewbooks_file(file_path)
                          print(result)
                          

                          עכשיו אני רק צריך כמה שיפורים קטנים ואז זה יהיה מושלם!

                          1] שהסקריפט ירוץ בלולאה על כל הקבצים שנמצאים בתיקייה [שממנה אני מפעיל אותו], [כולל תתי תיקיות עד סוף כל הדורות] או לחילופין שאוכל לבחור עם ממשק גרפי יותר נחמד אבל לא קריטי...
                          אבל שלא יהיה ח"ו התנגשויות בין תהליכים של הסקריפט בגלל זה.....
                          2] שבמקום לענות לי אמת או שקר, הוא פשוט יעביר את כל הקבצים שהם אמת לתיקייה מסוימת, ולא רק להעתיק שיהיה לי כפול... אלא להעביר ולמחוק לגמרי מהמקור....
                          3] ו... הכי טוב מקומפל.....

                          מי שיכול לעזור בזה אודה לו עמוקות!

                          @האדם-החושב.

                          א תגובה 1 תגובה אחרונה
                          2
                          • א אלף שין

                            @yzahn
                            מדהים הסקריפט שלך פשוט עובד נפלא!!
                            תודה רבה!!

                            from pymupdf import pymupdf
                            
                            def is_hebrewbooks_file(file_path):
                              doc = pymupdf.open(file_path)
                              page = doc[0]
                              text = page.get_text()
                              if text.find("hebrewbook") != -1:
                                return True
                              ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                              if ocr_text.find("hebrewbook") != -1:
                                return True
                              return False
                            
                            file_path = "40809.pdf"  # replace with your file path
                            result = is_hebrewbooks_file(file_path)
                            print(result)
                            

                            עכשיו אני רק צריך כמה שיפורים קטנים ואז זה יהיה מושלם!

                            1] שהסקריפט ירוץ בלולאה על כל הקבצים שנמצאים בתיקייה [שממנה אני מפעיל אותו], [כולל תתי תיקיות עד סוף כל הדורות] או לחילופין שאוכל לבחור עם ממשק גרפי יותר נחמד אבל לא קריטי...
                            אבל שלא יהיה ח"ו התנגשויות בין תהליכים של הסקריפט בגלל זה.....
                            2] שבמקום לענות לי אמת או שקר, הוא פשוט יעביר את כל הקבצים שהם אמת לתיקייה מסוימת, ולא רק להעתיק שיהיה לי כפול... אלא להעביר ולמחוק לגמרי מהמקור....
                            3] ו... הכי טוב מקומפל.....

                            מי שיכול לעזור בזה אודה לו עמוקות!

                            @האדם-החושב.

                            א מנותק
                            א מנותק
                            אלף שין
                            כתב נערך לאחרונה על ידי אלף שין
                            #33

                            @אלף-שין

                            import os
                            import glob
                            from pymupdf import pymupdf
                            import shutil
                            import tkinter as tk
                            from tkinter import filedialog
                            
                            def is_hebrewbooks_file(file_path):
                                if not file_path.endswith('.pdf'):
                                    return False
                                doc = pymupdf.open(file_path)
                                page = doc[0]
                                text = page.get_text()
                                if text.find("W") != -1 or text.find("w") != -1:
                                    return True
                                ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                if ocr_text.find("W") != -1 or ocr_text.find("w") != -1:
                                    return True
                                return False
                            
                            def main():
                                root = tk.Tk()
                                root.title("HebrewBooks File Finder")
                            
                                label = tk.Label(root, text="Select a directory:")
                                label.pack()
                            
                                dir_button = tk.Button(root, text="Browse", command=lambda: browse_dir())
                                dir_button.pack()
                            
                                result_label = tk.Label(root, text="")
                                result_label.pack()
                            
                                def browse_dir():
                                    dir_path = filedialog.askdirectory()
                                    if dir_path:
                                        current_dir = dir_path
                                        target_dir = "HebrewBooks"  # adjust this to your target directory
                                        os.makedirs(target_dir, exist_ok=True)  # create the target directory if it doesn't exist
                                        for root, dirs, files in os.walk(current_dir):
                                            for file in files:
                                                file_path = os.path.join(root, file)
                                                if os.path.isfile(file_path) and file_path.endswith('.pdf'):
                                                    if is_hebrewbooks_file(file_path):
                                                        shutil.move(file_path, os.path.join(target_dir, file))
                                                        result_label.config(text=f"Moved HebrewBook file: {file_path}")
                                                    else:
                                                        result_label.config(text="No HebrewBook files found")
                            
                                root.mainloop()
                            
                            if __name__ == "__main__":
                                main()
                            

                            זה עושה הכל ב"ה!
                            [עדיין יש מעט קבצים שה OCR לא מצליח לזהות אותם]

                            מישהוא יכול רק לקמפל אותו?

                            האדם החושבה תגובה 1 תגובה אחרונה
                            1
                            • א אלף שין

                              @אלף-שין

                              import os
                              import glob
                              from pymupdf import pymupdf
                              import shutil
                              import tkinter as tk
                              from tkinter import filedialog
                              
                              def is_hebrewbooks_file(file_path):
                                  if not file_path.endswith('.pdf'):
                                      return False
                                  doc = pymupdf.open(file_path)
                                  page = doc[0]
                                  text = page.get_text()
                                  if text.find("W") != -1 or text.find("w") != -1:
                                      return True
                                  ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                  if ocr_text.find("W") != -1 or ocr_text.find("w") != -1:
                                      return True
                                  return False
                              
                              def main():
                                  root = tk.Tk()
                                  root.title("HebrewBooks File Finder")
                              
                                  label = tk.Label(root, text="Select a directory:")
                                  label.pack()
                              
                                  dir_button = tk.Button(root, text="Browse", command=lambda: browse_dir())
                                  dir_button.pack()
                              
                                  result_label = tk.Label(root, text="")
                                  result_label.pack()
                              
                                  def browse_dir():
                                      dir_path = filedialog.askdirectory()
                                      if dir_path:
                                          current_dir = dir_path
                                          target_dir = "HebrewBooks"  # adjust this to your target directory
                                          os.makedirs(target_dir, exist_ok=True)  # create the target directory if it doesn't exist
                                          for root, dirs, files in os.walk(current_dir):
                                              for file in files:
                                                  file_path = os.path.join(root, file)
                                                  if os.path.isfile(file_path) and file_path.endswith('.pdf'):
                                                      if is_hebrewbooks_file(file_path):
                                                          shutil.move(file_path, os.path.join(target_dir, file))
                                                          result_label.config(text=f"Moved HebrewBook file: {file_path}")
                                                      else:
                                                          result_label.config(text="No HebrewBook files found")
                              
                                  root.mainloop()
                              
                              if __name__ == "__main__":
                                  main()
                              

                              זה עושה הכל ב"ה!
                              [עדיין יש מעט קבצים שה OCR לא מצליח לזהות אותם]

                              מישהוא יכול רק לקמפל אותו?

                              האדם החושבה מנותק
                              האדם החושבה מנותק
                              האדם החושב
                              מדריכים
                              כתב נערך לאחרונה על ידי
                              #34

                              @אלף-שין
                              sort.exe

                              א תגובה 1 תגובה אחרונה
                              1
                              • האדם החושבה האדם החושב

                                @אלף-שין
                                sort.exe

                                א מנותק
                                א מנותק
                                אלף שין
                                כתב נערך לאחרונה על ידי אלף שין
                                #35

                                @האדם-החושב
                                עדכון לכולם:
                                שכללתי ודייקתי את הסקריפט הרבה יותר,
                                וכעת עובד ללא תקלות בס"ד,
                                וכעת אצרף אותו לטובת כולם.

                                import os
                                import glob
                                from pymupdf import pymupdf
                                import shutil
                                import tkinter as tk
                                from tkinter import filedialog
                                import re
                                from tkinter import ttk
                                
                                def is_hebrewbooks_file(file_path):
                                    if not file_path.endswith('.pdf'):
                                        return False
                                    doc = pymupdf.open(file_path)
                                    page = doc[0]
                                    text = page.get_text()
                                    if (text.find("ww") != -1 or text.find("WW") != -1 or
                                            text.find("wbook") != -1 or text.find("WBOOK") != -1 or
                                            text.find("org") != -1 or
                                            re.search(r"https?://\S+", text) is not None):
                                        return True
                                    ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                    if (ocr_text.find("ww") != -1 or ocr_text.find("WW") != -1 or
                                            ocr_text.find("wbook") != -1 or ocr_text.find("WBOOK") != -1 or
                                            ocr_text.find("org") != -1 or
                                            re.search(r"https?://\S+", ocr_text) is not None):
                                        return True
                                    return False
                                
                                def browse_dir():
                                    dir_path = filedialog.askdirectory()
                                    if dir_path:
                                        current_dir = dir_path
                                        target_dir = "HebrewBooks"  
                                        os.makedirs(target_dir, exist_ok=True)  
                                        for root, dirs, files in os.walk(current_dir):
                                            for file in files:
                                                file_path = os.path.join(root, file)
                                                if os.path.isfile(file_path) and file_path.endswith('.pdf'):
                                                    if is_hebrewbooks_file(file_path):
                                                        shutil.move(file_path, os.path.join(target_dir, file))
                                                        progressbar["value"] += 1
                                                        progressbar.update_idletasks()
                                                    else:
                                                        result_label.config(text="No HebrewBook files found")
                                
                                def main():
                                    root = tk.Tk()
                                    root.title("HebrewBooks File Finder")
                                
                                    label = tk.Label(root, text="Select a directory:")
                                    label.pack()
                                
                                    dir_button = tk.Button(root, text="Browse", command=browse_dir)
                                    dir_button.pack()
                                
                                    global progressbar
                                    progressbar = ttk.Progressbar(root, orient="horizontal", length=200, mode="determinate")
                                    progressbar.pack()
                                
                                    global result_label
                                    result_label = tk.Label(root, text="")
                                    result_label.pack()
                                
                                    root.mainloop()
                                
                                if __name__ == "__main__":
                                    main()
                                

                                ועכשיו אבקש שוב ממי שיכול לקמפל אותו, לטובת כולם תבוא עליו ברכה!

                                [ספריות שצריך להוריד:
                                1] pip install pymupdf.
                                2] את התוכנה הזאת להתקין במחשב
                                3] pip install pytesseract

                                עריכה-
                                קימפלתי בס"ד בהצלחה!

                                להעתיק ולהוריד כוכביות

                                א תגובה 1 תגובה אחרונה
                                2
                                • א אלף שין

                                  @האדם-החושב
                                  עדכון לכולם:
                                  שכללתי ודייקתי את הסקריפט הרבה יותר,
                                  וכעת עובד ללא תקלות בס"ד,
                                  וכעת אצרף אותו לטובת כולם.

                                  import os
                                  import glob
                                  from pymupdf import pymupdf
                                  import shutil
                                  import tkinter as tk
                                  from tkinter import filedialog
                                  import re
                                  from tkinter import ttk
                                  
                                  def is_hebrewbooks_file(file_path):
                                      if not file_path.endswith('.pdf'):
                                          return False
                                      doc = pymupdf.open(file_path)
                                      page = doc[0]
                                      text = page.get_text()
                                      if (text.find("ww") != -1 or text.find("WW") != -1 or
                                              text.find("wbook") != -1 or text.find("WBOOK") != -1 or
                                              text.find("org") != -1 or
                                              re.search(r"https?://\S+", text) is not None):
                                          return True
                                      ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                      if (ocr_text.find("ww") != -1 or ocr_text.find("WW") != -1 or
                                              ocr_text.find("wbook") != -1 or ocr_text.find("WBOOK") != -1 or
                                              ocr_text.find("org") != -1 or
                                              re.search(r"https?://\S+", ocr_text) is not None):
                                          return True
                                      return False
                                  
                                  def browse_dir():
                                      dir_path = filedialog.askdirectory()
                                      if dir_path:
                                          current_dir = dir_path
                                          target_dir = "HebrewBooks"  
                                          os.makedirs(target_dir, exist_ok=True)  
                                          for root, dirs, files in os.walk(current_dir):
                                              for file in files:
                                                  file_path = os.path.join(root, file)
                                                  if os.path.isfile(file_path) and file_path.endswith('.pdf'):
                                                      if is_hebrewbooks_file(file_path):
                                                          shutil.move(file_path, os.path.join(target_dir, file))
                                                          progressbar["value"] += 1
                                                          progressbar.update_idletasks()
                                                      else:
                                                          result_label.config(text="No HebrewBook files found")
                                  
                                  def main():
                                      root = tk.Tk()
                                      root.title("HebrewBooks File Finder")
                                  
                                      label = tk.Label(root, text="Select a directory:")
                                      label.pack()
                                  
                                      dir_button = tk.Button(root, text="Browse", command=browse_dir)
                                      dir_button.pack()
                                  
                                      global progressbar
                                      progressbar = ttk.Progressbar(root, orient="horizontal", length=200, mode="determinate")
                                      progressbar.pack()
                                  
                                      global result_label
                                      result_label = tk.Label(root, text="")
                                      result_label.pack()
                                  
                                      root.mainloop()
                                  
                                  if __name__ == "__main__":
                                      main()
                                  

                                  ועכשיו אבקש שוב ממי שיכול לקמפל אותו, לטובת כולם תבוא עליו ברכה!

                                  [ספריות שצריך להוריד:
                                  1] pip install pymupdf.
                                  2] את התוכנה הזאת להתקין במחשב
                                  3] pip install pytesseract

                                  עריכה-
                                  קימפלתי בס"ד בהצלחה!

                                  להעתיק ולהוריד כוכביות

                                  א מנותק
                                  א מנותק
                                  אלף שין
                                  כתב נערך לאחרונה על ידי אלף שין
                                  #36

                                  @אלף-שין
                                  עדכון:
                                  סקריפט נוסף שממין אף הוא לפי המטא דאטה

                                  import os
                                  import PyPDF2
                                  import shutil
                                  from tkinter import Tk, filedialog, messagebox
                                  from tkinter import *
                                  
                                  class PDFSorter:
                                      def __init__(self, root):
                                          self.root = root
                                          self.root.title("PDF Sorter")
                                          self.script_path = os.path.dirname(__file__)
                                          self.folder_path = ""
                                  
                                          self.label_folder_path = Label(root, text="Select Folder:")
                                          self.label_folder_path.pack()
                                          self.button_folder_path = Button(root, text="Browse", command=self.browse_folder)
                                          self.button_folder_path.pack()
                                          self.entry_folder_path = Entry(root, textvariable=self.folder_path)
                                          self.entry_folder_path.pack()
                                  
                                          self.button_sort = Button(root, text="Sort PDFs", command=self.sort_pdfs)
                                          self.button_sort.pack()
                                  
                                      def browse_folder(self):
                                          self.folder_path = filedialog.askdirectory()
                                          self.entry_folder_path.delete(0, END)
                                          self.entry_folder_path.insert(0, self.folder_path)
                                  
                                      def get_meta_data(self, pdf_file):
                                          pdf = PyPDF2.PdfReader(pdf_file)
                                          meta_data = {}
                                          for key in pdf.metadata.keys():
                                              meta_data[key] = pdf.metadata[key]
                                          return meta_data
                                  
                                      def search_meta_data(self, meta_data, word):
                                          for key, value in meta_data.items():
                                              if isinstance(value, str) and word.lower() in value.lower():
                                                  return True
                                          return False
                                  
                                      def sort_pdfs(self):
                                          if not self.folder_path:
                                              messagebox.showerror("Error", "Please select a folder")
                                              return
                                  
                                          destination_folder = os.path.join(self.script_path, 'Hebrew Box')
                                          if not os.path.exists(destination_folder):
                                              os.makedirs(destination_folder)
                                  
                                          for root, dirs, files in os.walk(self.folder_path):
                                              for file in files:
                                                  if file.endswith('.pdf'):
                                                      pdf_file = os.path.join(root, file)
                                                      meta_data = self.get_meta_data(pdf_file)
                                                      if self.search_meta_data(meta_data, 'ID'):
                                                          dest_file_name = os.path.join(destination_folder, file)
                                                          if os.path.exists(dest_file_name):
                                                              counter = 1
                                                              while True:
                                                                  new_file_name = f"{file.split('.')[0]}({counter}).{file.split('.')[1]}"
                                                                  new_file_path = os.path.join(destination_folder, new_file_name)
                                                                  if not os.path.exists(new_file_path):
                                                                      dest_file_name = new_file_path
                                                                      break
                                                                  counter += 1
                                                          shutil.move(pdf_file, dest_file_name)
                                  
                                  if __name__ == '__main__':
                                      root = Tk()
                                      pdf_sorter = PDFSorter(root)
                                      root.mainloop()
                                  

                                  מקומפל
                                  עריכה- משום מה המקומפל לא עובד לי לע"ע,
                                  וצ"ע מ"ט,
                                  @האדם-החושב תוכל לבדוק מדוע? ואם כבר אולי אפשר לעשות סקריפט אחד גדול ומסודר.

                                  תגובה 1 תגובה אחרונה
                                  0
                                  • yzahnY yzahn

                                    @אלף-שין
                                    א) במקום pypdf אני משתמש עכשיו ב-pymupdf
                                    ב) תתקין במחשב שלך את זה

                                    הקוד הבא עובד על שלושת הקבצים שהבאת,
                                    אם יש לך עוד דוגמאות של קבצים שזה לא עובד עליהם אנא העלה את הקובץ לפה ונראה מה יש לעשות בנושא

                                    הנה הקוד:

                                    from pymupdf import pymupdf
                                    
                                    def is_hebrewbooks_file(file_path):
                                      doc = pymupdf.open(file_path)
                                      page = doc[0]
                                      text = page.get_text()
                                      if text.find("hebrewbook") != -1:
                                        return True
                                      # if failed - try ocr
                                      ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                      if ocr_text.find("hebrewbook") != -1:
                                        return True
                                      return False
                                    
                                    א מנותק
                                    א מנותק
                                    אלף שין
                                    כתב נערך לאחרונה על ידי אלף שין
                                    #37

                                    @yzahn כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                                    א) במקום pypdf אני משתמש עכשיו ב-pymupdf
                                    ב) תתקין במחשב שלך את זה

                                    שאלתי את GPT
                                    brought me the pymupdf model and told me to install software from this link https://github.com/UB-Mannheim/tesseract/releases/download/v5.4.0.20240606/tesseract-ocr-w64-setup-5.4.0.20240606.exe
                                    The question is, how do you add Hebrew to the software [except for Script]

                                    וענה לי

                                    To add Hebrew support to Tesseract-OCR, you need to install the Hebrew language pack and training data. Here's a step-by-step guide to do so:

                                    Step 1: Install the Hebrew language pack

                                    1. Download the Hebrew language pack from the official Tesseract-OCR website: Hebrew Language Pack
                                    2. Extract the downloaded ZIP file to a directory on your system, for example, C:\Tesseract\Hebrew

                                    Step 2: Install the Hebrew training data

                                    1. Download the Hebrew training data from the official Tesseract-OCR website: Hebrew Training Data
                                    2. Extract the downloaded ZIP file to the same directory as the language pack, C:\Tesseract\Hebrew

                                    Step 3: Add the Hebrew language pack to Tesseract-OCR

                                    1. Open the Tesseract-OCR installation directory (the one where you installed the software from the link you provided). By default, this is usually C:\Program Files_Tisesseract-OCR-5.4.0.20240606.
                                    2. Create a new directory named tessdata if it doesn't already exist.
                                    3. Move the extracted Hebrew language pack and training data files (*.traineddata files) to the tessdata directory.

                                    Here's the final structure:

                                    C:\Program Files_Tisesseract-OCR-5.4.0.20240606
                                    tessdata
                                    heb.traineddata
                                    hebr.traineddata
                                    ...
                                    

                                    Step 4: Configure Tesseract-OCR to use the Hebrew language pack

                                    1. Open a Command Prompt as an administrator.
                                    2. Navigate to the Tesseract-OCR installation directory: cd C:\Program Files_Tisesseract-OCR-5.4.0.20240606
                                    3. Run the following command to configure Tesseract-OCR to use the Hebrew language pack: tesseract -l heb path/to/your/pdf/file.pdf output

                                    Replace path/to/your/pdf/file.pdf with the actual path to the PDF file you want to recognize.

                                    Now, when you run your Python script with Pymupdf, Tesseract-OCR should recognize the Hebrew text in the PDF file with higher accuracy.

                                    If you encounter any issues, you can check the Tesseract-OCR logs for errors by running tesseract -l heb -v 2 path/to/your/pdf/file.pdf output (replace 2 with the verbosity level you prefer).

                                    התוכל לעזור לי בזה? [בפרט שהקישורים חסומים לי].

                                    א תגובה 1 תגובה אחרונה
                                    0
                                    • א אלף שין

                                      @yzahn כתב בשיתוף | שיתוף ובקשת עזרה, תוכנה למיון ספרים!:

                                      א) במקום pypdf אני משתמש עכשיו ב-pymupdf
                                      ב) תתקין במחשב שלך את זה

                                      שאלתי את GPT
                                      brought me the pymupdf model and told me to install software from this link https://github.com/UB-Mannheim/tesseract/releases/download/v5.4.0.20240606/tesseract-ocr-w64-setup-5.4.0.20240606.exe
                                      The question is, how do you add Hebrew to the software [except for Script]

                                      וענה לי

                                      To add Hebrew support to Tesseract-OCR, you need to install the Hebrew language pack and training data. Here's a step-by-step guide to do so:

                                      Step 1: Install the Hebrew language pack

                                      1. Download the Hebrew language pack from the official Tesseract-OCR website: Hebrew Language Pack
                                      2. Extract the downloaded ZIP file to a directory on your system, for example, C:\Tesseract\Hebrew

                                      Step 2: Install the Hebrew training data

                                      1. Download the Hebrew training data from the official Tesseract-OCR website: Hebrew Training Data
                                      2. Extract the downloaded ZIP file to the same directory as the language pack, C:\Tesseract\Hebrew

                                      Step 3: Add the Hebrew language pack to Tesseract-OCR

                                      1. Open the Tesseract-OCR installation directory (the one where you installed the software from the link you provided). By default, this is usually C:\Program Files_Tisesseract-OCR-5.4.0.20240606.
                                      2. Create a new directory named tessdata if it doesn't already exist.
                                      3. Move the extracted Hebrew language pack and training data files (*.traineddata files) to the tessdata directory.

                                      Here's the final structure:

                                      C:\Program Files_Tisesseract-OCR-5.4.0.20240606
                                      tessdata
                                      heb.traineddata
                                      hebr.traineddata
                                      ...
                                      

                                      Step 4: Configure Tesseract-OCR to use the Hebrew language pack

                                      1. Open a Command Prompt as an administrator.
                                      2. Navigate to the Tesseract-OCR installation directory: cd C:\Program Files_Tisesseract-OCR-5.4.0.20240606
                                      3. Run the following command to configure Tesseract-OCR to use the Hebrew language pack: tesseract -l heb path/to/your/pdf/file.pdf output

                                      Replace path/to/your/pdf/file.pdf with the actual path to the PDF file you want to recognize.

                                      Now, when you run your Python script with Pymupdf, Tesseract-OCR should recognize the Hebrew text in the PDF file with higher accuracy.

                                      If you encounter any issues, you can check the Tesseract-OCR logs for errors by running tesseract -l heb -v 2 path/to/your/pdf/file.pdf output (replace 2 with the verbosity level you prefer).

                                      התוכל לעזור לי בזה? [בפרט שהקישורים חסומים לי].

                                      א מנותק
                                      א מנותק
                                      אלף שין
                                      כתב נערך לאחרונה על ידי אלף שין
                                      #38

                                      @אלף-שין

                                      עדכון יום שלישי בבוקר:
                                      בס"ד @האדם-החושב עשה סקריפט אחד מסודר ומדויק מאד!
                                      הסקריפט כולל 4 שלבים למיון!
                                      נסו ותהנו!

                                      import os
                                      from pymupdf import pymupdf
                                      import re
                                      import PyPDF2
                                      import shutil
                                      from tkinter import Tk, filedialog
                                      
                                      def metadata(file_path):
                                              pdf = PyPDF2.PdfReader(file_path)
                                              meta_data = {}
                                              for key in pdf.metadata.keys():
                                                  meta_data[key] = pdf.metadata[key]
                                              for key, value in meta_data.items():
                                                  if isinstance(value, str) and metadata_word.lower() in value.lower():
                                                      return True
                                              return False
                                      
                                      def text_recognition(file_path):
                                          doc = pymupdf.open(file_path)
                                          page = doc[0]
                                          text = page.get_text()
                                          if (text.find("ww") != -1 or text.find("WW") != -1 or
                                                  text.find("wbook") != -1 or text.find("WBOOK") != -1 or
                                                  text.find("org") != -1 or
                                                  re.search(r"https?://\S+", text) is not None):
                                              return True
                                          return False
                                      
                                      
                                      def is_hebrewbooks_file_ocr_1(file_path):
                                          doc = pymupdf.open(file_path)
                                          page = doc[0]
                                          ocr_text = page.get_textpage_ocr(tessdata=r"C:\Program Files\Tesseract-OCR\tessdata").extractText()
                                          if (ocr_text.find("www") != -1 or ocr_text.find("WWW") != -1 or
                                                  ocr_text.find("wbook") != -1 or ocr_text.find("WBOOK") != -1 or
                                                  ocr_text.find("org") != -1 or
                                                  re.search(r"https?://\S+", ocr_text) is not None):
                                              return True
                                          return False
                                      
                                      def is_hebrewbooks_file_ocr_2(file_path):
                                          doc = pymupdf.open(file_path)
                                          page = doc[0]
                                          text = page.get_text()
                                          if (text.find("ww") != -1 or text.find("WW") != -1 or
                                                  text.find("wbook") != -1 or text.find("WBOOK") != -1 or
                                                  text.find("org") != -1 or
                                                  re.search(r"https?://\S+", text) is not None):
                                              return True
                                          return False
                                      
                                      
                                      
                                      
                                      def main():
                                          root = Tk()
                                          root.withdraw()
                                          books_folder = filedialog.askdirectory()
                                          global metadata_word
                                          metadata_word = "ID"
                                          for root, dirs, files in os.walk(books_folder):
                                              for file in files:
                                                  file_path = os.path.join(root, file)
                                                  if os.path.isfile(file_path) and file_path.endswith('.pdf'):
                                                      if metadata(file_path):
                                                          target_dir = "metadata"
                                                      elif text_recognition(file_path):
                                                          target_dir = "text recognition"
                                                      elif is_hebrewbooks_file_ocr_1(file_path):
                                                          target_dir = "ocr 1"
                                                      elif is_hebrewbooks_file_ocr_2(file_path):
                                                          target_dir = "ocr 2"
                                                      else:
                                                          continue
                                                      # Get the relative path from the source directory
                                                      relative_path = os.path.relpath(file_path, books_folder)
                                                      target_path = os.path.join(target_dir, relative_path)
                                                      target_folder = os.path.dirname(target_path)
                                                      os.makedirs(target_folder, exist_ok=True)
                                                      shutil.move(file_path, target_path)
                                      
                                      main()
                                      

                                      והנה מי שרוצה תוכנה מקומפלת להורדה
                                      [צריך להעתיק את הקישור ידנית [מקש ימני בעכבר על המילה להורדה] להדביק בשורת הכתובת בדפדפן, ולהוריד כוכביות!

                                      נ"ב: אם מישהוא יודע ויכול, נשמח לשיפור קטן,
                                      [להוסיף OCR בעברית לסקריפט,
                                      כדי שהזיהוי יהיה יותר מדויק].

                                      עדכון: בגלל הסירבול הרב כאן וכל הפוסטים הלא מסודרים וכו',
                                      פתחתי על זה שרשור חדש ומאיר עיניים כאן.

                                      תגובה 1 תגובה אחרונה
                                      3

                                      • התחברות

                                      • אין לך חשבון עדיין? הרשמה

                                      • התחברו או הירשמו כדי לחפש.
                                      • פוסט ראשון
                                        פוסט אחרון
                                      0
                                      • חוקי הפורום
                                      • פופולרי
                                      • לא נפתר
                                      • משתמשים
                                      • חיפוש גוגל בפורום
                                      • צור קשר