Last active
December 6, 2022 15:22
-
-
Save timabell/bc90e0808ec1cda173ca09225a16e194 to your computer and use it in GitHub Desktop.
set windows file associations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/timabell/bc90e0808ec1cda173ca09225a16e194 | |
# MIT license | |
$exts=@( | |
"csv", | |
"csproj", | |
"json", | |
"log", | |
"md", | |
"patch", | |
"sql", | |
"txt", | |
"xml") | |
echo "## setting up file associations" | |
foreach ($ext in $exts){ | |
$extfile=$ext+"file" | |
$dotext="." + $ext | |
cmd /c assoc $dotext=$extfile | |
cmd /c "ftype $extfile=""C:\Program Files (x86)\Notepad++\notepad++.exe"" ""%1""" | |
echo "" | |
} | |
# see also: | |
# * https://superuser.com/q/406985/8271 | |
# * https://gist.github.com/timabell/608fb680bfc920f372ac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
%1
should be in quotes (cmd /c "ftype $extfile=""C:\Program Files (x86)\Notepad++\notepad++.exe"" ""%1"""
), otherwise it breaks when opening files in folders with spaces, see notepad-plus-plus/notepad-plus-plus#4981 (comment)