Both sides previous revision
前次修改
|
|
it:batch-decode-url-file-names [2018/01/09 23:40] ghsrobert |
it:batch-decode-url-file-names [2019/04/06 07:09] (目前版本) ghsrobert 找到解法! |
所以,如果想讓 DokuWiki 改用 UTF-8 檔名的話,還得先把現有文件檔的 URL encoding 全部解碼才行。但哪裡有批次解碼的工具? | 所以,如果想讓 DokuWiki 改用 UTF-8 檔名的話,還得先把現有文件檔的 URL encoding 全部解碼才行。但哪裡有批次解碼的工具? |
| |
→ 找了一下找到[[https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding|這裡]]推薦 renameutils。[[http://www.nongnu.org/renameutils/|renameutils home]] 這裡有官方教學。 | * → 找了一下找到[[https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding|這裡]]推薦 renameutils。[[http://www.nongnu.org/renameutils/|renameutils home]] 這裡有官方教學。 |
| * 但 renameutils 似乎原本寫給 Linux 作業系統用,那 macOS 上怎辦? |
但 renameutils 似乎原本寫給 Linux 作業系統用,那 macOS 上怎辦? | * → 幸好 [[http://macappstore.org/renameutils/|Install renameutils on Mac OSX – Mac App Store]] 這邊有安裝教學。 |
| * → 裝好 renameutils 後,確實可以用 deurlname 這個指令批次解碼。但,它無法處理子目錄裡的檔案啊!!!QQ |
→ 幸好 [[http://macappstore.org/renameutils/|Install renameutils on Mac OSX – Mac App Store]] 這邊有安裝教學。 | * 這邊有一個要 25 歐元的 Windows 小軟體可以處理子目錄下的檔案:[[https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/urldecodefilenames.html|URL Decode Filenames - Convert Filenames - Overview]] |
| * 或像這篇說的 shell script 來在逐個子資料夾執行指令,有沒有搞頭?[[https://unix.stackexchange.com/questions/171677/cd-into-all-directories-execute-command-on-files-in-that-directory-and-return/171679|shell script - cd into all directories, execute command on files in that directory, and return to previous current directory - Unix & Linux Stack Exchange]] |
→ 裝好 renameutils 後,確實可以用 deurlname 這個指令批次解碼。但,它無法處理子目錄裡的檔案啊!!!QQ | * ↑/^20190404^/ 好像不完全正確,這邊講的只有進入各個資料夾,但是執行的指令是針對該資料夾本身做一次,而不是對資料夾內每個項目都執行 |
| * /^20190405^/ 目前試:<code bash>for d in ./* ; do (deurlname $d -v); done</code>是可以對「單一資料夾」每個項目都做的。接下來我需要的是能自動「進入每個資料夾」的步驟~ |
這邊有一個要 25 歐元的 Windows 小軟體可以處理子目錄下的檔案:[[https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/urldecodefilenames.html|URL Decode Filenames - Convert Filenames - Overview]] | * 結果看來好像還是要用 <code bash>find some/dir -type f -execdir somecommand {} \;</code> |
| * 但我需要搞懂最後面 ''{}'' 的意思 |
或像這篇說的 shell script 來在逐個子資料夾執行指令,有沒有搞頭?[[https://unix.stackexchange.com/questions/171677/cd-into-all-directories-execute-command-on-files-in-that-directory-and-return/171679|shell script - cd into all directories, execute command on files in that directory, and return to previous current directory - Unix & Linux Stack Exchange]] | * [[https://unix.stackexchange.com/questions/195939/what-is-meaning-of-in-finds-exec-command|What is meaning of {} + in find's -exec command? - Unix & Linux Stack Exchange]] |
| * [[https://unix.stackexchange.com/questions/108216/find-with-execdir|shell - find with -execdir - Unix & Linux Stack ExchangeC]] |
| * 及 ''\'' 的意思 |
| * 還是搞不太懂,但看來 ''{}'' 和 ''\'' 都省不了 ∴執行了:<code bash>$ find . -type f -execdir sh -c 'for d in ./*; do (deurlname $d -v); done' {} \;</code>大致上似乎是可以的(只要解碼後的名稱不要和已有的項目重複即可) |
| * 最後只要一行<code bash>find . -d -name "*%*" -exec deurlname {} -v \;</code>就搞定了!太神奇了!:D 感謝 神 |
| * 不需要套迴圈 |
| * find 的 ''-d'' 是先進下層執行,免得上層解碼後下層失聯 |