Skip to content

A powerful PowerShell script that automatically renames and organizes font files with standardized naming convention: Family (Subfamily) (vVersion).ext

License

Notifications You must be signed in to change notification settings

behify/powershell-font-renamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

PowerShell Font Renamer

A powerful PowerShell script that automatically renames and organizes font files with a standardized naming convention: Family (Subfamily) (vVersion).ext

🌟 Features

  • Smart Font Analysis: Automatically extracts font family, subfamily, and version information
  • Standardized Naming: Converts fonts to Family (Subfamily) (vVersion).ext format
  • Automatic Organization: Moves processed fonts to a separate folder, leaving only problematic fonts in the original directory
  • Comprehensive Logging: Creates detailed log files with timestamps for all operations
  • Simulation Mode: Test changes before applying them with -WhatIf parameter
  • Multiple Format Support: Works with TTF, OTF, WOFF, and WOFF2 files
  • Intelligent Subfamily Detection: Recognizes Bold, Italic, Light, Medium, Thin, Black, and combinations
  • Version Extraction: Attempts to extract actual version information from font files and filenames

📋 Requirements

  • Windows PowerShell 5.1 or later
  • .NET Framework (included with PowerShell)
  • Windows operating system

🚀 Installation

  1. Download the FontRenamer.ps1 script
  2. Place it in your fonts directory or any preferred location
  3. Open PowerShell in that directory
  4. Load the script functions:
    . .\FontRenamer.ps1

💡 Usage

Basic Commands

# Load the script
. .\FontRenamer.ps1

# Show help information
Show-Help

# Test run (simulation mode - no actual changes)
Rename-Fonts -WhatIf

# Process fonts in current directory
Rename-Fonts

# Process fonts in specific directory
Rename-Fonts -Path "C:\MyFonts"

Example Output

Processing fonts in: C:\Fonts

Processing: Arial-Bold.ttf
  Detected: Family='Arial', Subfamily='Bold', Version='1.0'
  SUCCESS: Renamed and moved to: C:\Fonts\Processed_Fonts\Arial (Bold) (v1.0).ttf

Processing: Roboto-LightItalic-v2.1.otf
  Detected: Family='Roboto', Subfamily='Light Italic', Version='2.1'
  SUCCESS: Renamed and moved to: C:\Fonts\Processed_Fonts\Roboto (Light Italic) (v2.1).otf

=== SUMMARY ===
Total fonts found: 15
Renamed and moved: 8
Moved unchanged: 5
Errors (remained in original folder): 2

All processed fonts moved to: C:\Fonts\Processed_Fonts
Only fonts with errors remain in: C:\Fonts
Log file saved: C:\Fonts\FontRenamer_Log_2025-08-24_14-30-25.txt

📁 Directory Structure After Processing

Your_Fonts_Directory/
├── Processed_Fonts/                    # Successfully processed fonts
│   ├── Arial (Bold) (v1.0).ttf
│   ├── Roboto (Light Italic) (v2.1).otf
│   ├── OpenSans (Regular) (v1.0).woff
│   └── ...
├── ProblemFont1.ttf                    # Fonts with extraction errors
├── CorruptFont2.otf                    # Fonts that couldn't be processed
└── FontRenamer_Log_2025-08-24_14-30-25.txt  # Detailed operation log

🎯 Naming Convention Examples

Before After
Arial-Bold.ttf Arial (Bold) (v1.0).ttf
Roboto-LightItalic.otf Roboto (Light Italic) (v1.0).otf
OpenSans-Regular-v2.1.woff OpenSans (Regular) (v2.1).woff
Montserrat-ExtraBoldItalic.woff2 Montserrat (ExtraBold Italic) (v1.0).woff2

🔍 Supported Font Formats

  • .ttf - TrueType Font
  • .otf - OpenType Font
  • .woff - Web Open Font Format
  • .woff2 - Web Open Font Format 2.0

🏷️ Subfamily Recognition

The script intelligently detects various font styles:

  • Weight: Thin, Light, Regular, Medium, SemiBold, Bold, ExtraBold, Black
  • Style: Italic, Normal
  • Combinations: Bold Italic, Light Italic, Medium Italic, etc.

📊 Version Detection

The script attempts to extract version information from:

  1. Font metadata - Internal font version strings
  2. Filename patterns - Version numbers in filenames (v2.1, Version1.5)
  3. Fallback - Defaults to v1.0 if no version found

🛡️ Safety Features

  • Simulation Mode: Always test with -WhatIf before making changes
  • Comprehensive Logging: Every operation is logged with timestamps
  • Error Handling: Gracefully handles corrupt or problematic fonts
  • File Conflict Prevention: Checks for existing files before renaming
  • Original File Preservation: Problematic fonts remain untouched

📝 Log Files

Each run generates a detailed log file with:

  • Timestamp and execution mode
  • Font analysis results (Family, Subfamily, Version)
  • Success/failure status for each operation
  • Final summary with statistics
  • Full path information for moved files

⚙️ Advanced Usage

Custom Processing Directory

Rename-Fonts -Path "D:\FontCollection" -WhatIf

Verbose Logging

Rename-Fonts -Verbose

Processing Only Specific Formats

The script automatically processes all supported formats. To handle only specific types, you can filter the directory contents first.

🔧 Troubleshooting

Common Issues

  1. "Execution Policy" Error

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  2. "Cannot extract font info" Errors

    • File may be corrupted
    • Unsupported font format
    • File permissions issue
  3. Functions Not Recognized

    • Make sure to load the script with dot sourcing: . .\FontRenamer.ps1

Getting Help

  • Use Show-Help command for quick reference
  • Check the generated log files for detailed error information
  • Ensure you have proper read/write permissions in the target directory

📄 License

MIT License - feel free to use, modify, and distribute.

🤝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

📧 Support

If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.


Made with ❤️ for font enthusiasts and designers

About

A powerful PowerShell script that automatically renames and organizes font files with standardized naming convention: Family (Subfamily) (vVersion).ext

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published