Created
December 28, 2015 13:44
-
-
Save Paldom/a878624b8a80db01db79 to your computer and use it in GitHub Desktop.
Batch font installation from subfolders. Specially for easier Google Font sync.
This file contains hidden or 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
## 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