Last active
May 9, 2020 13:46
-
-
Save ToshY/9c7f1a57fd25ede7810b0b4d8a84df76 to your computer and use it in GitHub Desktop.
Adds new fonts from specified directory
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
# "Automatically" adds font but for some reason it still needs user interaction when the file already exists | |
function addNewFonts{ | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$dir | |
) | |
if($dir[-1] -ne [IO.Path]::DirectorySeparatorChar){$dir = $dir + [IO.Path]::DirectorySeparatorChar} | |
$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14) | |
Get-ChildItem -Path ($dir + '*') -Include @('*.ttf','*.otf') | % { $fonts.CopyHere($_.fullname, 16) } | |
} | |
addNewFonts -dir 'D:\fonts' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment