2023年5月31日 星期三

只要點兩下,就能將一堆的Doc與Docx 轉成 PDF

系列文章:
01.python 不管何時何地,只要點兩下,資料夾內的所有pdf都會合併成一個pdf
https://skjhcreator.blogspot.com/2022/06/pythonpdfpdf.html
02.python 只要點兩下,分別對各資料夾內的pdf合併,合併後的檔名要讓人知道來自哪個資料夾 
https://skjhcreator.blogspot.com/2022/06/python-pdf.html
03. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF
03.https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html
04.只要點兩下,就能將一堆的JPG轉成一個PDF,並以JPG所在的資料夾名稱為PDF的檔名
04.https://skjhcreator.blogspot.com/2023/06/jpgpdfjpgpdf.html
05.只要點兩下,就能將放進input的一堆PDF轉成各自的WORD
05.https://skjhcreator.blogspot.com/2023/10/inputpdfword.html
06.只要點兩下,就能將放進input的一堆PDF轉成在ouput資料夾內的各自的WORD 
06.https://skjhcreator.blogspot.com/2023/10/inputpdfouputword.html
07.只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF
07.https://skjhcreator.blogspot.com/2024/09/word-word-pdf.html
08.只要點兩下,就可以將資料夾input內的所有Word通通轉成一個PDF
08.https://skjhcreator.blogspot.com/2025/07/inputwordpdf.html
09.只要點兩下兩次,就能依照設定拆分指定PDF頁數並合併成設定好的一個PDF
09.https://skjhcreator.blogspot.com/2025/09/pdfpdf.html
10.只要點兩下,就能將input資料夾內所有PDF進行容量壓縮
10.https://skjhcreator.blogspot.com/2026/04/inputpdf.html

Just two clicks and you can convert a bunch of Doc and Docx files into PDF format.
 
        最近遇到一個問題,想要把一堆的Word 轉成PDF。當然可以用手動的方式,一個個用Word打開,另存新檔,然後另存成PDF。可是這樣很麻煩,要是有100多個以上的Doc與Docx,然後要一一打開後再另存成PDF。有沒有更快的方法!!只要讓我點兩下滑鼠,不管有多少個Doc與Docx就能自動轉換成PDF?
 
        I recently encountered a problem where I wanted to convert a bunch of Word files into PDFs. Of course, I could do it manually by opening each file in Word, saving it as a new file, and then saving it as a PDF. But that's very tedious, especially if there are more than 100 Doc and Docx files that need to be converted. Is there a faster way? Ideally, I would like to be able to convert all of the files to PDF with just two clicks of the mouse, regardless of how many Doc and Docx files there are.
                     下載檔案。解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):

安裝pywin32套件(Install the pywin32 suite)
指令(command):pip install pywin32

程式名稱(Program name):Word2Pdf.py
程式內容(Code):
# pip install pywin32
import glob
import os
from win32com import client

path=os.getcwd()
os.chdir(path+'\\input\\')
word = client.Dispatch("Word.Application")

for i in glob.glob('*.doc'):
    print("Convert "+path+'\\input\\'+i+" to PDF!")
    doc = word.Documents.Open(path+'\\input\\'+i)
    doc.SaveAs("{}.pdf".format(path+'\\output\\'+i[:-4]),17)
    print("{}.pdf".format(path+'\\output\\'+i[:-4])+" OK!")
    doc.Close()
for i in glob.glob('*.docx'):
    print("Convert "+path+'\\input\\'+i+" to PDF!")
    docx = word.Documents.Open(path+'\\input\\'+i)
    docx.SaveAs("{}.pdf".format(path+'\\output\\'+i[:-5]),17)
    print("{}.pdf".format(path+'\\output\\'+i[:-5])+" OK!")
    docx.Close()

word.Quit()


資料來源:

2023年4月18日 星期二

只要點兩下,免傳輸線,就能讓學生透過QRcode來傳送IPAD或平板內的檔案


        由於教育部生生有平板計畫,讓每一位學生都能透過IPAD或平板來進行學習。但是在電腦教室內,希望學生能夠將檔案傳到教師電腦。除了傳輸線、隨身碟等這一類的工具,一部一部將檔案傳到老師機。還有其他辦法讓學生將檔案傳到學校老師的電腦裡嗎?要用行動載具來進行教學。若沒有傳輸線,但有區域無線網路與筆電。我該如何將載具內檔案傳送到我的筆電內?
 

只要如上圖布置硬體,下載檔案,解壓縮下載檔案,對著Open.bat點兩下。就能產生QRcode接下來用行動載具拍下此QRcode,就能連接到筆電的HFS。
                     下載檔案。解壓密碼:demo1234
使用教學:

        
      以下是程式碼:
目的:只要點兩下,就能產生本機IP的QRcode
程式名稱:IpQRcode.py
程式內容:
import socket
import qrcode

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
print('http://'+ip)
img = qrcode.make('http://'+ip)
img.show()
s.close()

目的:只要點兩下,直接開啟hfs.exe與IpQRCode.exe
程式名稱:Open.bat
程式內容:

@echo off
start %~dp0\IpQRcode\hfs.exe %~dp0\IpQRcode\1.vfs
start %~dp0\IpQRcode\IpQRCode.exe

 

資料來源:

3.HFS 

2023年3月28日 星期二

只要點兩下,就能啟用、更名、停用與還原Administrator帳號

        最近接到通知,希望能夠將公用電腦的Administrator帳號->啟用、更名、停用。老實說,一點都不想花時間去一台一台設定。只想著讓自己輕鬆地完成這件事。因此,就開始著手撰寫BAT。啟用Administrator更名後停用.BAT。但為了能夠測試,也順便開發了還原名稱為Administrator.BAT與檢視過程.BAT

        下載檔案。解壓密碼:demo1234
使用步驟教學:

        如何檢視程式碼正確執行?
詳細教學步驟:
1.確認內部使用者:
   點選[檢視過程.BAT]->[使用者],就可以看出所有使用者狀況->[關閉視窗]
2.啟用、更名、停用Administrator帳號
點選[啟用Administrator更名後停用.BAT]->點選[檢視過程.BAT]
就可以看到Administrator更名為OK,並且停用。接下來,關閉所有視窗。
3.還原Administrator帳號
點選[還原名稱為Administrator.BAT]->點選[檢視過程.BAT]
就可以看到OK還原為Administrator,並且停用


        以下是程式碼:
目的:只要點兩下,就能啟用、更名、停用Administrator帳號
程式名稱:啟用Administrator更名後停用.BAT
程式內容:
@echo off
REM ================設定Administrator更名的名稱===
set AdministratorRename=OK
REM ================以下為程式碼==================
REM 啟用 administrator
net user administrator /active:yes
REM 將 Administrator 更名為 AdministratorRename變數值
wmic UserAccount where Name="Administrator" call Rename Name="%AdministratorRename%"
REM 停用 %AdministratorRename%
net user %AdministratorRename% /active:no
pause
exit

目的:只要點兩下,就能還原Administrator帳號
程式名稱:還原名稱為Administrator.BAT
程式內容:
@echo off
REM ================設定Administrator更名的名稱===
set AdministratorRename=OK
REM ================以下為程式碼==================
REM 啟用 %AdministratorRename%
net user %AdministratorRename% /active:yes
REM 將 AdministratorRename變數值 回復 Administrator
wmic UserAccount where Name="%AdministratorRename%" call Rename Name="Administrator"
REM 停用 administrator
net user administrator /active:no
pause
exit

目的:檢視過程
程式名稱:檢視過程.BAT
程式內容:
@echo off
REM 開啟本機使用者和群組
lusrmgr.msc


資料來源:

2023年2月21日 星期二

只要點兩下,就能離開位子。讓電腦依照規劃自動下載YT多媒體

 系列文章:

1.只要點兩下,就能離開位子。讓電腦依照規劃自動下載YT影片https://skjhcreator.blogspot.com/2022/11/youtube.html
2.只要點兩下,就能離開位子。讓電腦依照公開的PlayList自動下載YT多媒體https://skjhcreator.blogspot.com/2022/11/playlistyoutube.html
3.只要點兩下,就能離開位子。讓電腦依照規劃自動下載臉書的影片https://skjhcreator.blogspot.com/2022/11/facebook.html
4.只要點兩下,就能離開位子。讓電腦依照規劃自動下載YT多媒體https://skjhcreator.blogspot.com/2023/02/yt.html
5.變更套件,重寫程式。只要點兩下,就能離開位子。讓電腦依照規劃自動下載YT影片https://skjhcreator.blogspot.com/2025/10/yt.html
下載檔案。解壓密碼:demo1234
MP4下載使用步驟教學:
MP3下載使用步驟教學:

     感恩員東國小徐千惠資訊組長的建議。
     由於學生練舞需要有配樂。除了下載影片MP4,也能下載MP3,希望能簡便使用。換言之,只要貼上所有網址,只要點兩下就能將MP3或MP4下載。在2.只要點兩下,就能離開位子。讓電腦依照公開的PlayList自動下載YT多媒體中,利用公開playlist,來下載MP3或MP4。現在則改寫1.只要點兩下,就能離開位子。讓電腦依照規劃自動下載YT影片的程式碼,讓其可以下載MP3。


程式碼:
檔案名稱:P001.py
程式內容:
from pytube import YouTube
from pytube.cli import on_progress
import os

class YouTubeDownloader:
    def __init__(self,URL,FolderPath):
        self.Url = URL
        self.FolderPath = FolderPath
   
    def onProgress(self,stream,chunk,remains):
        total = stream.filesize
        percent = (total-remains)/total*100
        print(f'下載中… {percent:05.2f}%', end='\r')

    def YTDownloader(self):
        yt = YouTube(self.Url,on_progress_callback=self.onProgress)
        print(yt.title+" downloading....")
        yt.streams.filter().get_highest_resolution().download(self.FolderPath)
        print("Download "+yt.title+" OK!")

    def YTMp3Downloader(self):
        yt = YouTube(self.Url,on_progress_callback=self.onProgress)
        print(yt.title+".mp4"+" downloading....")
        yt.streams.filter().get_audio_only().download(self.FolderPath)
        print("Download "+yt.title+".mp4"+" OK!")



class OpenFiles():
    #開啟檔案

    def __init__(self,FileName,FolderName):
        self.FileName = FileName
        self.FolderName = FolderName
   
    def FileContentList(self):
        #設定信件內容檔名並取得檔案內容並回傳List
        ContentFileName = str(os.path.abspath(os.getcwd()))+"\\"+self.FileName
        ContentFile = open(ContentFileName,'r')
        FileContentList = ContentFile.readlines()
        ContentFile.close()
        return FileContentList
   
    def GetFolderPath(self):
        #取得資料夾路徑
        if os.path.exists(self.FolderName):
            FolderPath = str(os.path.abspath(os.getcwd()))+"\\"+self.FolderName
        else:
            os.mkdir(self.FolderName)
            FolderPath = str(os.path.abspath(os.getcwd()))+"\\"+self.FolderName

        return FolderPath
   
fcl = OpenFiles('下載名單.txt','').FileContentList()
gfp = OpenFiles('','download').GetFolderPath()
TempType = OpenFiles('Mp3orMp4.txt','').FileContentList()
TempType.pop(0)
for i in fcl:
    temp=i.replace('\n','')
    for k in TempType:
        if k.upper() == 'MP3':
            YouTubeDownloader(temp,gfp).YTMp3Downloader()
        elif k.upper() =='MP4':
            YouTubeDownloader(temp,gfp).YTDownloader()

for i in TempType:
    if i.upper() =='MP3':
        print("**************************************************")
        print("您選擇下載mp3檔案,由於編碼的關係,下載時檔案為mp4")
        print("請您於下載完畢後,點選[轉換副檔名為mp3.bat]")
        print("[轉換副檔名為mp3.bat]會完成轉換副檔名由mp4改為mp3")
        print("*************************************************")
       
os.system("pause")
os.system("exit")

檔案名稱:轉換副檔名為mp3.bat
程式內容:
@echo off
REM 讀取檔案

for /f "skip=1 delims=" %%a in (Mp3orMp4.txt) do (
    set mp3txt=%%~a
)
echo %mp3txt%
if "%mp3txt%"=="mp3" (
cd  %~dp0\download\
ren *.mp4 *.mp3
)

PAUSE
EXIT

資料來源:

2023年1月30日 星期一

教育版雲端硬碟設定或解除容量上限的步驟

        感恩大成國小黃俊凱組長分享。
        根據共用雲端硬碟當前的預設設定,機構中的所有人都能建立數量不限的共用雲端硬碟,而且可存放的內容量也沒有上限,因此可能會占用太多儲存空間。為因應上述情況,我們將於 2023 年 1 月逐步推行下列異動措施:

        如果管理員尚未在頂層機構單位 (OU) 中設定共用雲端硬碟儲存空間上限,該機構單位的每個共用雲端硬碟都會套用 100 GB 的上限。
設定方式請參考附圖:



2023年1月29日 星期日

Xoops 網站從原先sslforfree憑證改用公用憑證的安裝步驟


壹、第一次設定:
自縣網中心取得檔案,其檔案內容如下圖:


一、下載與解壓縮eCA1_GTLSCA.zip,取得eCA1_GTLSCA.crt
$wget https://gtlsca.nat.gov.tw/download/eCA1_GTLSCA.zip
$unzip eCA1_GTLSCA.zip

二、變更已下載簽發之 SSL 伺服器軟體憑證(*.cer)檔名為server.cer
$mv 3E0F555985B24E84092C96C1762173B4.cer server.cer

三、將SSL伺服軟體憑證由DER編碼格式轉換成PEM編碼格式
$openssl x509 -in server.cer -inform DER -out server.crt

四、整合server.crt eCA1_GTLSCA.crt 為 server-chain.crt,再更名為server.crt
$cat server.crt eCA1_GTLSCA.crt > server-chain.crt
$mv server-chain.crt server.crt

五、將server.crt  與 myserver.key 分別複製到 /etc/ssl 與 /etc/ssl/private
目前只需要兩個檔案,分別是server.crt  與 myserver.key
將server.crt  與 myserver.key 分別複製到 /etc/ssl 與 /etc/ssl/private。即
server.crt         --->    /etc/ssl
myserver.key  --->    /etc/ssl/private
其指令如下:
$mv server.crt  /etc/ssl
$mv myserver.key  /etc/ssl/private

六、修改default-ssl.conf 與 000-default.conf
檔案名稱default-ssl.conf
檔案修改內容:
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite EECDH+AES128:EECDH+AES256:EECDH+CAMELLIA:!ECDSA:!MD5
SSLHonorCipherOrder on
SSLCertificateFile  /etc/ssl/server.crt
SSLCertificateKeyFile  /etc/ssl/private/myserver.key
將原先的設定作註解
                # SSLCertificateFile /etc/ssl/certificate.crt
                # SSLCertificateKeyFile /etc/ssl/private/private.key
                # SSLCertificateChainFile  /etc/ssl/ca_bundle.crt
整個狀況如下圖:

檔案名稱000-default.conf
檔案修改內容:
將原先的設定作註解
# Redirect permanent / https://abc.def.ghi.tw
其內容如下:

七、重啟Apache2
$sudo service apache2 restart

貳、日後處理
一、將縣網中心取得的檔案送至 /home/webadmin/PublicCert
二、修改CertReplacement.sh 黃色部分名稱
三、執行CertReplacement.sh

檔案名稱:CertReplacement.sh
檔案內容:
#!/bin/bash
wget https://gtlsca.nat.gov.tw/download/eCA1_GTLSCA.zip
unzip eCA1_GTLSCA.zip
mv 3E0F555985B24E84092C96C1762173B4.cer server.cer
openssl x509 -in server.cer -inform DER -out server.crt
cat server.crt eCA1_GTLSCA.crt > server-chain.crt
mv server-chain.crt server.crt
mv server.crt  /etc/ssl
mv myserver.key  /etc/ssl/private
service apache2 restart

資料來源:


2023年1月16日 星期一

只要點兩下,就能寄送全校教職員薪資單 for Windows 7 x64


        由於先前開發的程式在Windows 10 x64 與 Python 3.9.0 環境中編譯,適用Win 10 x64。但還是無法在出納組電腦執行,換句話說,原先的案主依舊無法享受便利--點兩下,就可以寄送寄送全校教職員薪資單。因此,必須想法子來處理。

 最後重新編譯程式:
下載檔案。解壓密碼:demo1234
教學影片:


1.在出納組電腦點兩下後,為何無法寄出全校教職員薪資單?
   原因在出納組電腦作業系統為 Windows 7 x64 SP1,需改用Python 3.8.6 以前的版本重新編譯。
2. 目前實作,Python編譯環境如下:
(1)虛擬機:VMware Player 6.0
(2)作業系統:Windows 7 x64 SP1
(3)更新套件:KB4457144
(4)Python版本:3.8.01.
(5)Python編輯程式:Visual Studio Code  版本:1.50.1

        編譯PyGmail.py,需事先安裝Python 套件如下:
(1)Pyinstaller
    安裝指令: pip install pyinstaller
(2)Openpyxl
    安裝指令: pip install openpyxl

        編譯PyGmail.py
    編譯指令:pyinstaller -F PyGmail.py




資料來源:





        

Ubuntu 26.04:Apache + Django + MySQL 正式部署

系列文章: 1.在 Ubuntu 26.04 建立 Django 開發環境 2.Ubuntu 26.04:Apache + Django + MySQL 正式部署 以 Apache 2.4、 mod_wsgi 、Python 虛擬環境及 MySQL 8.4 部署 D...