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

NewPlus supports using variables such as yyyyMMdd in template folder names or file names #35332

Open
NightWatch0 opened this issue Oct 9, 2024 · 4 comments
Labels
Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams

Comments

@NightWatch0
Copy link

Description of the new feature / enhancement

NewPlus supports using template strings such as yyyyMMdd (represent the current date) in template folder names or file names.

For example, in “%LocalAppData%\Microsoft\PowerToys\NewPlus\Templates” there are the following folders:

"${yyyyMMdd}: Title"
"${ParentFolderName}-PartA"

When I used the first template on 2024-10-10, it generated:

"20241010: Title"

And when I used the second template inside the "Work" folder, it generated:

"Work-PartA"

In addition, it should be possible to use specific variables to specify the part of the file name that needs to be modified after creating a new file. Usually, after creating a new file, it will switch to the rename file state and select the entire file name in the rename text box, as shown below.
Snipaste_2024-10-09_10-33-08
But most of the time, only specific parts need to be modified. For example, creating a template folder with variables above to get "20241010: Title", user only need to change the last word "Title" to the name of a specific item.
Snipaste_2024-10-09_10-33-41

So I want to be able to use a tag like # to specify the part of the file name that actually needs to be modified, to change the cursor/selection behavior when automatically renaming after creating the file.
The resulting template folder name may look like this:

"${yyyyMMdd}: #Title#"

Scenario when this would be used?

This method can expand the flexibility of the NewPlus module and reduce a large number of renaming operations. It does not introduce too many complex operations, and only requires changing the file name of the template file.

Supporting information

no

@NightWatch0 NightWatch0 added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Oct 9, 2024
@pa-0
Copy link

pa-0 commented Oct 9, 2024

This would be great. No clue if it's possible but providing some functionality that parallels the regex replacement rules we already use in PowerRename would also be great.

Obviously a very naive example but something like:

TitleRule = "$FolderName ${start=1,increment=1}"

Where applying the above is decided based on rules like:

If Path Matches Pattern = **\testruns\**
Then $Foldername="testrun[:digit:]"

Then using a NewPlus to apply a folder template in the directory C:\users\User\src\project\testruns\, the existing contents of which are as follows:

testruns\
|
|__testrun1
|
|__testrun2

would result in a new folder called testrun3 created.

@cgaarden
Copy link
Contributor

Really like these ideas, thank you for sharing.

I've started working on some variable support (date and time related, environment variables, and the parent folder name), and hope to release those in a future update. See also #35287 (comment)

I'm not sure how to enter a partial rename mode, if anyone has pointers please share.

@NightWatch0
Copy link
Author

NightWatch0 commented Nov 23, 2024

There is an alternative solution to enter partial rename mode by floating a text input window to enter the partial text. This can support users to enter multiple custom variables, for example, there is a template like this:

${yyyyMMdd}: #Title#-#Group#
│
├─#Title#-Begin-#Group#
│
├─#Title#-Stage1-#Group#
│
├─#Title#-Stage2-#Group#
│
├─#Title#-Stage3-#Group#
│
├─#Title#-Stage4-#Group#
│
└─#Title#-End-#Group#

Use multiple text input boxes provided by PoweyToys (similar to the following diagram) to replace the native renaming behavior of Windows, which can easily input the two user variables #Title# and #Group#.
Image
Image
Just enter the value of #Title#, then press Tab or Enter, and then press Enter again. Then the final input will be like:

20241124: ProjectA-Group7
│
├─ProjectA-Begin-Project
│
├─ProjectA-Stage1-Group7
│
├─ProjectA-Stage2-Group7
│
├─ProjectA-Stage3-Group7
│
├─ProjectA-Stage4-Group7
│
└─ProjectA-End-Group7

@cgaarden
Copy link
Contributor

Great point, that would work!

I might add something along those lines later on, after getting a couple of other things done.

Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams
Projects
None yet
Development

No branches or pull requests

3 participants