Download tools/export_docs.ps1 from Lashtw/idle: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/Lashtw/idle/resolve/main/tools/export_docs.ps1
- Command line
-
hf download hf://spaces/Lashtw/idle/tools/export_docs.ps1
-
curl -L -o export_docs.ps1 https://huggingface.co/spaces/Lashtw/idle/resolve/main/tools/export_docs.ps1
1.1 kB
| # 將 題庫 資料夾中的 .doc/.docx 轉成「篩選過的 HTML」(保留圖片),輸出到 tools/_export | |
| # 用法:powershell -ExecutionPolicy Bypass -File tools\export_docs.ps1 | |
| $root = Split-Path -Parent $PSScriptRoot | |
| # 避免中文路徑字面值的編碼問題:抓 root 底下第一個「非 tools/data/js/css」的資料夾當題庫來源 | |
| $src = Get-ChildItem $root -Directory | Where-Object { @('tools','data','js','css','.git','node_modules','.agents') -notcontains $_.Name } | Select-Object -First 1 | |
| $out = Join-Path $PSScriptRoot "_export" | |
| New-Item -ItemType Directory -Force -Path $out | Out-Null | |
| $word = New-Object -ComObject Word.Application | |
| $word.Visible = $false | |
| $word.DisplayAlerts = 0 | |
| try { | |
| Get-ChildItem $src.FullName -File | Where-Object { $_.Extension -match '^\.docx?$' } | ForEach-Object { | |
| $doc = $word.Documents.Open($_.FullName, $false, $true) | |
| $target = Join-Path $out ($_.BaseName + ".htm") | |
| # 10 = wdFormatFilteredHTML | |
| $doc.SaveAs2([string]$target, 10) | |
| $doc.Close([ref]$false) | |
| Write-Output ("OK " + $_.Name) | |
| } | |
| } finally { | |
| $word.Quit() | |
| } | |