將所學整合成你專屬的自動化系統
定義:根據你的工作需求,將多個工具和步驟串連成一個流暢的自動化流程
# my-workflow.ps1
# 我的日常文件處理工作流
param(
[string]$Action = "help"
)
switch ($Action) {
"convert" {
# 轉換收件匣中的所有 Markdown
Get-ChildItem "D:\收件匣\*.md" | ForEach-Object {
pandoc $_.FullName -o "D:\輸出\$($_.BaseName).docx"
}
Write-Host "轉換完成!"
}
"cleanup" {
# 移動已處理的檔案到歸檔
Move-Item "D:\收件匣\*.md" "D:\歸檔\"
Write-Host "清理完成!"
}
"report" {
# 生成今日報告
$date = Get-Date -Format "yyyy-MM-dd"
# ... 報告生成邏輯
}
default {
Write-Host "用法: .\my-workflow.ps1 -Action [convert|cleanup|report]"
}
}
D:\我的工具\
├── scripts\
│ ├── convert-all.ps1
│ ├── watch-folder.ps1
│ └── daily-report.ps1
├── templates\
│ ├── report-template.docx
│ └── meeting-template.md
├── samples\
│ └── test-files\
└── README.md
# quick-convert.ps1
# 快速轉換:雙擊執行或拖放檔案
param(
[string]$InputFile
)
# 如果沒有輸入檔案,開啟檔案選擇對話框
if (!$InputFile) {
Add-Type -AssemblyName System.Windows.Forms
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "Markdown files (*.md)|*.md"
if ($dialog.ShowDialog() -eq 'OK') {
$InputFile = $dialog.FileName
} else {
exit
}
}
# 轉換
$output = [System.IO.Path]::ChangeExtension($InputFile, ".docx")
pandoc $InputFile -o $output
# 完成提示
Write-Host "已轉換: $output" -ForegroundColor Green
Read-Host "按 Enter 關閉"
讓工具觸手可及,才會真正使用它!
1列出你最常處理的 3 種文件任務
2為每個任務建立一個腳本
3整理到個人腳本庫資料夾
4建立桌面捷徑方便使用
5實際使用一週並優化
記住:最好的工具是你會用的工具,持續使用和改進才是關鍵!
你已經掌握了 Antigravity + Pandoc 的核心技能
感謝你的學習,祝你工作順利!