Skip to content

Instantly share code, notes, and snippets.

@ToshY
Last active May 9, 2020 13:46
Show Gist options
  • Save ToshY/9c7f1a57fd25ede7810b0b4d8a84df76 to your computer and use it in GitHub Desktop.
Save ToshY/9c7f1a57fd25ede7810b0b4d8a84df76 to your computer and use it in GitHub Desktop.
Adds new fonts from specified directory
# "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