Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New+ Support for variables in template filenames (35287) #37074

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

cgaarden
Copy link
Contributor

@cgaarden cgaarden commented Jan 25, 2025

Summary of the Pull Request

Added support for variables in template filenames

Variables supported includes

  1. Date and time component variables, such as $YYYY, $YY, $MM, $DD, - using the same syntax and implementation as in PowerRename
  2. $PARENT_FOLDER_NAME - will replace variable with the name of the parent folder
  3. %environment-variable% - will replace variable with the value of the corresponding environment variable

Example:
Template filename:
$YYYY-$MM-%DD, $hh - $PARENT_FOLDER_NAME by %USERNAME%

Filename on create becomes:
2025-01-25, 02 - PowerShell project by cgaarden

PR Checklist

Detailed Description of the Pull Request / Additional comments

SHFileOperation API related

Still using SHFileOperation API - may change this in a future PR as the current implementation requires iterating through files multiple times (not really that impactful unless a template folder contains 100s+ of files/subfolders
Fixed an issue on ARM64 when depending on SHFileOperation to provide filename remapping

Minor refactoring

To help with support the variable support

Minor exception handling logic

To help get information on where New+ menu isn't being displayed

Validation Steps Performed

  1. Windows 10 clean install, with lots of different template permutations
  2. Windows 11 clean and update install, with lots of different template permutations
  3. Windows 11 ARM64 and x64, with lots of different template permutations
  4. Template folders with subitems with multiple variables within filenames
  5. Template items starting with digits and spaces, e.g. 13. $YYYY-$MM-$DD PTA meeting minutes and actions
  6. Rename mode is entered as expected for files and folder based templates, also when creating template with same name multiple times (x) in Arabic script
  7. Validated that GPO ConfigureEnabledUtilityNewPlus, NewPlusHideTemplateFilenameExtension, NewPlusReplaceVariablesInTemplateFilenames are working as intended

Example template folder + corresponding context menu

image

Example of project including subitems

image

New+ settings

(debug)
image

New+ related GPO policies

image

This comment has been minimized.

@jaimecbernardo jaimecbernardo self-requested a review February 5, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant