Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is the easiest way to permanently change association (program which opens etc.) for several file extensions at once?

What I mean?

Let's say you used TextEditorUncool up until now to open txt, dat, bat and abc files. Now you got TextEditorReallyCool and you wish if there was an application which on the left had a name of the program, and on the right a list of file extensions associated with it (which it, let's say, opens).

Is there such a thing?

Usually programs change this thing during installation (some even ask before), but in the case of portable programs one usually has to do it by hand, and for editors which open a gazillion of different file extensions, it gets tiresome really fast.

All ideas welcomed !

share|improve this question
add comment

3 Answers 3

To change or create a file association from File Types list

If Open With command is not available, try the following steps:
Click Start, and then click Control Panel.
Click Folder Options.
Click File Types tab in Folder Options window and the full file types and their association will be listed.
Click New and type the File Extension in the box and then click Advanced.
Choose an association for the file type.
Click OK and then click Close.
Open the file again.

share|improve this answer
    
Wouldn't that be rather slow if you're often trying to change 30 extensions? –  ldigas Sep 18 '12 at 1:14
    
Well, it's faster than the other way... –  imtheman Sep 18 '12 at 1:17
    
Ok, fair enough ... –  ldigas Sep 18 '12 at 1:27
add comment

About one year ago, I wrote a small batch script to deal such text file association issue. I works in most time, but sometimes (after windows update applied, for example) the association will restore to default, if it happened, I will run the batch again.

I picked my 3 favorite text editors in the batch script.

  • Notepad2 (or Notepad2-mod) for lightweight text files. Default installation directory: %SystemRoot%
  • Notepad++ for .sql .sh. Default installation directory: %ProgramFiles%\Notepad++
  • EditPlus for most programming language text files. Default installation directory: %ProgramFiles%\EditPlus 3

You need change them to your favorite text editor, and you need change the corresponding file types to yours.

@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
share|improve this answer
    
Liu, this is even better than what I had in mind. Set once, apply forever. It's rather late in now (4 am), but I'm trying this out first thing in the morning! –  ldigas Sep 18 '12 at 2:18
add comment

Some programs that might come in handy:

Something else of interest (since you mentioned portable apps specifically) might be Coffee, which can be used to temporarily open all specified file types using your portable apps. So for example if you have a portable text editor on your USB stick, you could configure Coffee (also residing on the same stick) to associate the .txt extension with the editor. That way, as long as Coffee is running, .txt files will automatically open in the portable editor. Close Coffee, and voila, your .txt association will be reset back to what it was earlier!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.