2020年9月16日 星期三

auto-py-to-exe 轉換PY程式成為EXE

Step1:

安裝執行auto-py-to-exe圖形GUI界面之PYTHON轉換EXE套件程式

Step2:

將前個PYTHON程式( PYTHON旋轉PDF之程式載入),即可產出EXE執行檔


參考資訊:

auto-py-to-exe PYTHON轉換成EXE執行檔套件


PYTHON提供旋轉rorate PDF

下面為PYTHON自訂旋轉PDF (將下列紅色部分,貼在Notepad記事本,另存成RoratePDF.py)

 # importing the required modules彙入相關必要之模組 

import PyPDF2 

import sys

#'開啟檔案總管 (開啟轉換後之檔案使用)'

import subprocess

#'開啟GUI 取得來源檔(找出欲旋轉之PDF檔案)

import tkinter as tk

from tkinter import filedialog


root = tk.Tk()

root.withdraw()


FilePathName = filedialog.askopenfilename(initialdir = "/",title = "Select file for rotate (選擇欲旋轉之PDF檔案)",filetypes = (("PDF files","*.pdf"),("all files","*.*")))


  

def PDFrotate(origFileName, newFileName, rotation): 

  

    # creating a pdf File object of original pdf 

    pdfFileObj = open(origFileName, 'rb') 

      

    # creating a pdf Reader object 

    pdfReader = PyPDF2.PdfFileReader(pdfFileObj) 

  

    # creating a pdf writer object for new pdf 

    pdfWriter = PyPDF2.PdfFileWriter() 

      

    # rotating each page 

    for page in range(pdfReader.numPages): 

  

        # creating rotated page object 

        pageObj = pdfReader.getPage(page) 

        pageObj.rotateClockwise(rotation) 

  

        # adding rotated page object to pdf writer 

        pdfWriter.addPage(pageObj) 

  

    # new pdf file object 

    newFile = open(newFileName, 'wb') 

      

    # writing rotated pages to new file 

    pdfWriter.write(newFile) 

  

    # closing the original pdf file object 

    pdfFileObj.close() 

      

    # closing the new pdf file object 

    newFile.close() 

      

  

def main(): 

  

    # original pdf file name 

    origFileName = FilePathName

     

    # new pdf file name 

    newFileName = 'rotated_example.pdf'

      

    # rotation angle 自訂旋轉角度

    rotation_data = int(input("Enter a rotation angle(90、180): "))

      

    # calling the PDFrotate function 

    PDFrotate(origFileName, newFileName, rotation_data) 

      

if __name__ == "__main__": 

    # calling the main function 

    main() 


ListALLCD_2_DISK 僅列出全數光碟之檔案,另獨立出各目錄

將下列紅色部分,另存新檔至桌面   ListALLCD_2_DISK.cmd  ,存檔後點選執行。


rem  將前次處理舊檔案予以清除d:\listcd.txt

SET MYFILE="d:\listcd.txt"

IF EXIST %MYFILE% DEL /F %MYFILE%


rem 假設光碟槽在E槽

dir e: /s/w/o/p/a:-d >>d:\listcd.txt


rem 利用EXCEL檔,去開啟光碟臚列出全數檔案(依各自目錄,僅列出檔案),但EXCEL檔路徑,可能要自行修改

"C:\Program Files\Microsoft Office\Office16\EXCEL.EXE" d:\listcd.txt


參考資訊:

DIR命令提示資訊

(日文)dir 命令提示 列出檔案