-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
cgaarden
wants to merge
14
commits into
microsoft:main
Choose a base branch
from
cgaarden:New+feature-35287-support-for-variables-in-templates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New+ Support for variables in template filenames (35287) #37074
cgaarden
wants to merge
14
commits into
microsoft:main
from
cgaarden:New+feature-35287-support-for-variables-in-templates
Conversation
This file contains 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
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-template-filename
…upport-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…upport-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
This comment has been minimized.
This comment has been minimized.
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…https://github.com/cgaarden/PowerToys into New+feature-35287-support-for-variables-in-templates
…ables-in-templates
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Added support for variables in template filenames
Variables supported includes
$YYYY
,$YY
,$MM
,$DD
, - using the same syntax and implementation as in PowerRename$PARENT_FOLDER_NAME
- will replace variable with the name of the parent folder%environment-variable%
- will replace variable with the value of the corresponding environment variableExample:
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
PowerToys New+ variable support in template filenames -- documentation related updates MicrosoftDocs/windows-dev-docs#5285
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
Example template folder + corresponding context menu
Example of project including subitems
New+ settings
(debug)
![image](https://private-user-images.githubusercontent.com/14098831/406699407-be1ca7f1-b148-4cd3-aab3-60cc27b35e3a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDMwNzEsIm5iZiI6MTczOTE0Mjc3MSwicGF0aCI6Ii8xNDA5ODgzMS80MDY2OTk0MDctYmUxY2E3ZjEtYjE0OC00Y2QzLWFhYjMtNjBjYzI3YjM1ZTNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDIzMTI1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlZTg1OGE4ODlmODA4M2Y1ZjhlOTRiNTU4YmQ4MDJmZGQ1NjliMDJmZDE1Yzc0YzJkZDk3NGFhMjIwZjQzY2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.E92-VBUOdQrkE1tZ1tWTQhSyAYoGzE0KVll8XU1gRD8)
New+ related GPO policies