透過批次一次將一堆不關聯的檔案副檔名與 Notepad++ 關聯

透過批次一次將一堆不關聯的檔案副檔名與 Notepad++ 關聯

我有數千個擴展名為「.0」、「.1」、「.2」等的文件,我想將它們與 Notepad++ (v7.5.8) 關聯。它們目前在 Windows (Windows 10) 中沒有任何檔案關聯。由於他們沒有任何現有的關聯,因此解決方案此處顯示不為我工作。

另外,我希望在 Windows 中關聯它們,而不是在 N++ 設定中,因為我從 Windows 資源管理器存取這些檔案。

答案1

在我看來,比手動關聯所有.#檔案更容易的是使用 regedit 設定一個包羅萬象的編輯模式:

  • HKEY_CLASSES_ROOT\*\shell:新增鍵= Notepad++,設定(Default)=Edit with &Notepad++
  • HKEY_CLASSES_ROOT\*\shell\Notepad++:新增 Key = command,設定(Default)"c:\program files (x86)\notepad++\notepad++.exe" "%1"-- 使用適合您系統的 notepad++.exe 的正確路徑,並確保路徑和 %1 兩邊都有雙引號,以確保正確處理空格。

登出並重新登錄,或重新啟動。現在,在資源管理器中的任何文件上,您應該能夠右鍵單擊,選擇Edit with Notepad++,瞧!


每個分機關聯(所有使用者)

或者,打開一個cmd.exe視窗(如果需要,以管理員身份運行),然後運行

assoc .1=DotNumber
ftype DotNumber="c:\program files (x86)\notepad++\notepad++.exe" "%1"
for %n in (0 1 2 3 4 5 6 7 8 9) DO assoc .%n=DotNumber 

如果您想要更多.#擴展,請將它們新增至 for 迴圈。如果您想從批次檔(setdotn-assoc.batsetdotn-assoc.cmd)而不是在cmd.exe提示下設定它們,則需要兩個%而不是一個,其他一切都相同:

assoc .1=DotNumber
ftype DotNumber="c:\program files (x86)\notepad++\notepad++.exe" "%1"
for %%n in (0 1 2 3 4 5 6 7 8 9) DO assoc .%%n=DotNumber

每個擴充關聯(僅適用於目前使用者)

如果您遇到權限問題全部用戶,您可以嘗試執行每個擴充功能關聯,但僅限於目前使用者。

如果您能夠建立 DotNumber 類型,ftype DotNumber=請刪除現有定義。

從命令列執行以下命令(這次甚至不需要管理員命令列)

REG ADD     HKCU\Software\Classes\DotNumber                      /ve /d "DotNumber File" /f
REG ADD     HKCU\Software\Classes\DotNumber\Shell                /ve /d "open" /f
REG ADD     HKCU\Software\Classes\DotNumber\Shell\open           /ve /d "open DotNumber file" /f
REG ADD     HKCU\Software\Classes\DotNumber\Shell\open\command   /ve /d "\"c:\program files (x86)\notepad++\notepad++.exe\" \"^%1\"" /f
FOR %n in (0 1 2 3 4 5 6 7 8 9) DO REG ADD HKCU\Software\Classes\.%n /ve /d "DotNumber" /f

如果你想檢查它是否被寫入

REG QUERY   HKCU\Software\Classes\DotNumber /S
FOR %n in (0 1 2 3 4 5 6 7 8 9) DO REG QUERY HKCU\Software\Classes\.%n /S

相關內容