Skip to content

Instantly share code, notes, and snippets.

@Paldom
Created December 28, 2015 13:44
Show Gist options
  • Save Paldom/a878624b8a80db01db79 to your computer and use it in GitHub Desktop.
Save Paldom/a878624b8a80db01db79 to your computer and use it in GitHub Desktop.
Batch font installation from subfolders. Specially for easier Google Font sync.
## gfonts.ps1 ##
<#
.SYNOPSIS
Script that installs ttf fonts from subfolders recursively, e.g. for batch Google Font install
.NOTES
File Name: gfonts.ps1
Author: Domonkos Pal - [email protected]
License: MIT
#>
# http://stackoverflow.com/questions/16023238/installing-system-font-with-powershell
function InstallFont ($loc) {
$FONTS = 0x14
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($FONTS)
$objFolder.CopyHere($loc)
}
function DfsFontInstall ($dir) {
foreach($file in Get-ChildItem $dir) {
if($file.Attributes -ne 'Directory') {
if ($file.Extension -eq '.ttf') {
InstallFont $file.FullName;
Write-Output "Font $($file.Name) has been installed.";
}
} else {
DfsFontInstall $file.FullName;
}
}
}
DfsFontInstall;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment