更改文件扩展名关联


1

一次永久更改多个文件扩展名的关联(程序打开等)的最简单方法是什么?

我的意思是说?

比方说你用过 TextEditorUncool 到现在为止开放 文本 DAT 蝙蝠 ABC 文件。现在你有了 TextEditorReallyCool 并且你希望如果有一个应用程序在左边有一个程序的名称,在右边有一个与之关联的文件扩展名列表(比如打开它)。

有这样的事吗?

通常程序会在安装过程中改变这个问题(有些人甚至会问过),但是在便携式程序的情况下,人们通常需要手工完成,对于打开大量不同文件扩展名的编辑器来说,它会非常快速。

欢迎所有想法!

Answers:


1

大约一年前,我写了一个小批量脚本来处理这样的文本文件关联问题。我工作的大部分时间,但有时(例如,在应用Windows更新后),关联将恢复为默认值,如果发生,我将再次运行批处理。

我在批处理脚本中选择了我最喜欢的3个文本编辑器。

您需要将它们更改为您喜欢的文本编辑器,并且需要将相应的文件类型更改为您的文件类型。

@echo off

echo --------------------------------------------------------------------------
echo Windows text file association
echo --------------------------------------------------------------------------

REM ----------------------------------------------------------------------------
REM References
REM ----------------------------------------------------------------------------
REM Windows file associations
REM http://vim.wikia.com/wiki/Windows_file_associations
REM
REM Managing Files from the Command Line - Assoc and Ftype
REM http://commandwindows.com/assoc.htm
REM
REM Adding Associations
REM http://winbeginners.com/articles/associations3.htm
REM
REM CClean scan result show some error about registry HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
REM
REM http://superuser.com/questions/212848/how-change-file-association
REM
REM Windows registry information for advanced users
REM http://support.microsoft.com/kb/256986
REM ----------------------------------------------------------------------------

REM setlocal enabledelayedexpansion 
set PROGRAM_DIR=%%ProgramFiles%%
if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" set PROGRAM_DIR=%%ProgramFiles(x86)%%

REM notepad2
set NOTEPAD2=%%SystemRoot%%\notepad2.exe

REM Notepad++
set NPP=%PROGRAM_DIR%\Notepad++\notepad++.exe
if not exist "%ProgramFiles%\Notepad++\notepad++.exe" set NPP=%NOTEPAD2%

REM EditPlus
set EDITPLUS=%PROGRAM_DIR%\EditPlus 3\editplus.exe
if not exist "%ProgramFiles%\EditPlus 3\editplus.exe" set EDITPLUS=%NPP%

REM ----------------------------------------------------------------------------
REM Text file
REM ----------------------------------------------------------------------------
assoc .csv=txtfile
REM CueSheet
assoc .cue=txtfile

REM ----------------------------------------------------------------------------
REM C/C++
REM ----------------------------------------------------------------------------
assoc .h=SourceCode.C
assoc .c=SourceCode.C
assoc .hpp=SourceCode.C
assoc .cpp=SourceCode.C
assoc .cxx=SourceCode.C
assoc .rc=SourceCode.C
assoc .inc=SourceCode.C
REM AMXModX Script
assoc .sma=SourceCode.C


REM ----------------------------------------------------------------------------
REM Java
REM ----------------------------------------------------------------------------
assoc .java=SourceCode.Java
REM BeanShell
assoc .bsh=SourceCode.Java
REM ZK Script
assoc .zs=SourceCode.Java

REM ----------------------------------------------------------------------------
REM C#
REM ----------------------------------------------------------------------------
assoc .cs=SourceCode.CSharp

REM ----------------------------------------------------------------------------
REM SQL
REM ----------------------------------------------------------------------------
assoc .sql=sqlfile

REM ----------------------------------------------------------------------------
REM Web
REM ----------------------------------------------------------------------------
REM assoc .css=CSSfile
REM assoc .html=htmlfile
REM assoc .htm=htmlfile
assoc .shtml=htmlfile
REM assoc .js=jsfile

assoc .htc=htcfile

assoc .zul=SourceCode.ZK.UI
assoc .zhtml=SourceCode.ZK.UI
assoc .jsp=SourceCode.JSP
assoc .jspx=SourceCode.JSP

assoc .php=SourceCode.PHP

assoc .asp=SourceCode.ASP
assoc .aspx=SourceCode.ASP


REM ----------------------------------------------------------------------------
REM Shell
REM ----------------------------------------------------------------------------
assoc .awk=SourceCode.Shell
assoc .sed=SourceCode.Shell
assoc .sh=SourceCode.Shell
assoc .ps=SourceCode.PowerShell

REM assoc .bat=batfile
REM assoc .cmd=cmdfile
REM 对于批处理文件,不修改默认关联,而仅仅修改“编辑”动作的关联

REM ----------------------------------------------------------------------------
REM Configuration
REM ----------------------------------------------------------------------------
REM assoc .ini=inifile
REM assoc .inf=inffile
assoc .cfg=cfgfile
assoc .conf=Configuration.POSIX
assoc .properties=Configuration.Java

assoc .svg=svgfile
REM reg add


REM ----------------------------------------------------------------------------
REM Misc
REM ----------------------------------------------------------------------------
REM assoc .dsn=ODBC.FileDSN
REM assoc .eml=Microsoft Internet Mail Message
REM assoc .hta=htafile
REM assoc .jnlp=JNLPFile
REM assoc .log=txtfile
assoc .m3u=m3ufile
REM assoc .mht=mhtmlfile
REM assoc .mhtml=mhtmlfile
REM assoc .nfo=MSInfo.Document
REM assoc .reg=regfile
REM assoc .rtf=rtffile
REM assoc .scp=txtfile
REM SELinux Targeted policy .te
assoc .te=txtfile
REM assoc .txt=txtfile
REM assoc .wsc=scriptletfile
REM assoc .WSF=WSFFile
REM assoc .WSH=WSHFile
REM assoc .wtx=txtfile
REM assoc .xaml=Windows.XamlDocument
REM assoc .xhtml=xhtmlfile
REM assoc .xml=xmlfile


call :np2_open txtfile inifile jsfile cfgfile Configuration.POSIX Configuration.Java
call :np2_edit batfile cmdfile jsfile WSFFile WSHFile regfile m3ufile ODBC.FileDSN "Microsoft Internet Mail Message"

call :ep_open cssfile xmlfile xslfile xsltfile SourceCode.C SourceCode.Java SourceCode.CSharp SourceCode.JSP SourceCode.PHP SourceCode.ASP SourceCode.ZK.UI
call :ep_edit xmlfile svgfile htmlfile xhtmlfile shtmlfile htafile htcfile rtffile JNLPFile

call :npp_open SourceCode.Shell SourceCode.PowerShell sqlfile

pause


goto :EOF

:np2_open
if "%~1"=="" goto :EOF
REM echo %NOTEPAD2%  [Open]  %1
ftype %1="%NOTEPAD2%" "%%1"
shift
goto np2_open

:np2_edit
if "%~1"=="" goto :EOF
echo %NOTEPAD2%  [Edit]  %1
reg add "HKLM\Software\Classes\%~1\shell\edit\command" /ve /t REG_EXPAND_SZ /f /d "\"%NOTEPAD2%\" \"%%1\""
shift
goto np2_edit


:npp_open
if "%~1"=="" goto :EOF
REM echo %NPP%  [Open]  %1
ftype %1="%NPP%" "%%1"
shift
goto npp_open

:npp_edit
if "%1"=="" goto :EOF
echo %NPP%  [Edit]  %1
reg add "HKLM\Software\Classes\%~1\shell\edit\command" /ve /t REG_EXPAND_SZ /f /d "\"%NPP%\" \"%%1\""
shift
goto npp_edit


:ep_open
if "%~1"=="" goto :EOF
REM echo %EDITPLUS%  [Open]  %1
ftype %1="%EDITPLUS%" "%%1"
shift
goto ep_open

:ep_edit
if "%~1"=="" goto :EOF
echo %EDITPLUS%  [Edit]  %1
reg add "HKLM\Software\Classes\%~1\shell\edit\command" /ve /t REG_EXPAND_SZ /f /d "\"%EDITPLUS%\" \"%%1\""
shift
goto ep_edit

刘,这比我想的要好。设置一次,永久申请。现在已经很晚了(早上4点),但我早上第一件事就是尝试这个!
Rook

0

从“文件类型”列表中更改或创建文件关联

如果 打开用 命令不可用,请尝试以下步骤:
点击 开始 ,然后单击 控制面板
点击 文件夹选项
点击 文件类型 标签 文件夹选项 窗口和完整的文件类型及其关联将被列出。
点击 并在框中键入文件扩展名,然后单击“确定” 高级
选择文件类型的关联。
点击 然后单击
再次打开文件。


如果您经常尝试更改30个扩展程序,那会不是很慢?
Rook

嗯,它比其他方式更快......
imtheman

好,可以 ...
Rook

0

一些可能派上用场的程序:

其他感兴趣的东西(因为你特别提到了便携式应用程序)可能是 咖啡 ,可以用来 暂时 使用便携式应用打开所有指定的文件类型。因此,例如,如果您的USB记忆棒上有便携式文本编辑器,您可以配置Coffee(也位于同一个记忆棒上)以将.txt扩展名与编辑器相关联。这样,只要Coffee正在运行,.txt文件就会在便携式编辑器中自动打开。关闭咖啡,瞧,您的.txt关联将重置为之前的状态!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.