microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.74k stars 6.52k forks source link

[PowerRename] improved enumeration / incremental counter #3814

Closed wigster closed 1 year ago

wigster commented 4 years ago

Summary of the new feature/enhancement

Example: imported images from a camera are named

      IMG_3156 -> IMG_3259

in sequential order.

And I would like to rename them

     RomanticFailure_040_TopSecret -> RomanticFailure_143_TopSecret

Right now (0.18) there doesn't seem to be a way to do this (unless it is possible by massaging RegEx sufficiently, but I am too unfamiliar, in which case some documentation would be v helpful). There is the enumerate items option, but it just seems to always add a sequential counter starting from 1 and appended as (#)

Proposed technical implementation details (optional)

I guess it would be good if there were some sort of variable, e.g. $COUNTER, which would contain the number of the file being process and that could be inserted in an arbitrary place in the Replace with field.

It would be helpful if simple mathematical operation could be applied to it, e.g.

(2*$counter+5)

would actually produce a sequence of files named 5, 7,9,11,13.

I suppose some way to specify padded zeros, or a number format would be good, so that we would get 05, 07, 11, 13.

Crutkas: this should able to be included not just at the end, but anywhere in the string

PaulCoddington commented 4 years ago

Even a simple counter that is applied optionally as a suffix or prefix based on the current name sort order would be handy (although a datetime ordering option would also be useful).

My current workaround is to select all files in File Explorer, rename the first file with an arbitrary placeholder name, such as "item", then use PowerRename in two passes to clean up the mess.

So, renaming all selected files as "item" in File Explorer results in files being renamed as "item (1)", "item (2), "item (3)", etc, (in the same order as they were alphabetically sorted, which is handy if they were previously numerically sequenced then culled and you want to renumber them to eliminate gaps).

PowerRename is then used in a first pass to replace "item (" with "", then in a second pass to replace ")" with "", so that the files end up being named "1", "2", "3", etc. Or to build a sequence based on a date, where instead of "item" I would use, say "20200501_", but then there is still the problem of having to manually add leading zeros to some filenames if you want all to be the same length.

You have to take care because PowerRename will rename files with leading or trailing spaces if you mistake a space character for "" in the dialog! This leads to other applications being upset (File Explorer has trouble renaming them).

enricogior commented 3 years ago

from https://github.com/microsoft/PowerToys/issues/5833#issue-676137941

It is essential to be able to use incrementing numbers for file renaming. You already have the Enumerate Item option, but it is limited and sometimes not suitable. For example what if i wanted my counter start at 15, or i don't want the encapsulating round brackets.

Please consider implementing the Regular Expression Counter Operations: https://www.funduc.com/regexp.htm#Regular%20Expression%20Counters http://searchandreplace.helpmax.net/en/regular-expressions/regular-expression-counters/

It is in the format %1>15> (which substitutes $1) and means: use the first match in the expression and increment each match starting with number 15. If no starting value is given %1>> would use the starting value of the first match found.

htcfreek commented 3 years ago

from #7402 (comment)

In addition a feature like on linux where I can create filenames with counted nunbers and character would be great.

Example

Terminal command touch Image{A..C}{0..9}.jpg

Created Files

ImageA0.jpg, ImageA1.jpg, ..., ImageA9.jpg, ImageB0.jpg, ..., ImageB9.jpg, ..., ImageC9.jpg
tonycoculuzzi commented 3 years ago

The Enumerate Items option is too limited. This doesn't work for naming conventions with unique formatting requirements. What if we need leading 0s? What if we need the enumeration to be 0-indexed?

Something that would work well as an alternative would be adding a custom variable pattern. This variable pattern could use 0 or 1 to change the indexing, and the number of characters for the number of leading zeroes required.

For example:

$0 ---> [0, 1, 2, ..] $00 --> [00, 01, 02, ..] $000 -> [000, 001, 002, ..]

$1 ---> [1, 2, 3, ..] $11 --> [01, 02, 03, ..] $111 -> [001, 002, 003, ..]

As it stands, the current Enumerate Items feature is to limited to use in any kind of development environment.

Does anyone even like seeing their files enumerated with parentheses? πŸ˜…

chuzzbot commented 2 years ago

All selected Items should be able to have a prefix applied ( easily without knowledge of codes or symbols) and renumbered with padding without any special knowledge.

ghylander commented 2 years ago

any progress on this? honestly, current numbering system isn't very useful

adding an element like the current date system would be OK, something like $ddd (each d represents a digit). Shouldn't create conflict as the day of the week is represented by capital D

franky920920 commented 2 years ago

@ghylander Sadly, not yet. This issue does welcome all community pull requests. Feel free to contribute to this if anyone is able to. Just make sure to let us know here and follow our contributing guidelines! πŸ˜„

Chianti commented 2 years ago

Here's a great idea - someone should write a spellchecker that doesn't show you the correct spelling. How about a weather app that doesn't include the temperature? I know... DAW without a record button! Or perhaps an bulk renamer that doesn't have useful enumeration?

PwrSrg commented 2 years ago

Here's a great idea - someone should write a spellchecker that doesn't show you the correct spelling. How about a weather app that doesn't include the temperature? I know... DAW without a record button! Or perhaps an bulk renamer that doesn't have useful enumeration?

I actually really like the spellchecker idea! Force the user to LEARN how to spell. πŸ˜†

Let's Kickstart this ASAP! 🀩🀩🀩

jjnxpct commented 2 years ago

I would love to see some more enumation options in PowerRename. Can we expect this in the near future? Would be great. Unfortunately I am not able to create a pull request.

ThisTemba commented 2 years ago

Would really love this feature. Was literally the only reason I downloaded PowerToys because I thought I could number a bunch of files.

Chianti commented 2 years ago

Would really love this feature. Was literally the only reason I downloaded PowerToys because I thought I could number a bunch of files.

This is the one I use instead: http://www.den4b.com/products/renamer It may take you 15mins to learn how to use it, but once you've got the hang of it, it's pretty easy. Free version is fine for anything I usually need to do.

jameslashmar commented 2 years ago

Please add this functionality!

Also I think this could be simplified. Advanced renamer does a great job of this.

These could be added as 'quick tokens' just like the date and time variables that are already implemented into PowerRenamer at the minute so that you don't have to figure out the regEx everytime just to rename a few hundred files.

Advanced renamer does it in a nice way. See image below

image

Also, Global Renamer (an After Effects plugin from AeScripts) does a nice job too image

RyKilleen commented 2 years ago

Providing the index as a variable in the Replace field would be a really great approach to making everyone happy here, I think!

Fabiwolter commented 2 years ago

The current Enumeration option is completely useless, please do this cmon

Derpford commented 2 years ago

The ability to use, say, letters in place of numbers would also be fantastic (especially for people like me who have workflows that use letters for animation frame identifiers).

Snowdrama commented 2 years ago

Just came across this looking for this exact feature, definitely a needed one! For now guess I need to find another tool for this.

locomoco28 commented 2 years ago

A little work around I've found is by renaming twice using RegExp. First add the required amount of prefix zeros, then remove them using RegExp

First iteration file-(\d+)\.png -> file-00$1.png

Second iteration file-(\d+)(\d{3})\.png -> file-$2.png (only keep the 3 digits in the second group)

ghost commented 2 years ago

Can I work on implementing this feature?

htcfreek commented 2 years ago

@kokabi1365 Sure. You can create a PR. Feel free to ask for help if needed.

I think an easy syntax like I suggest in my comment above would be great: https://github.com/microsoft/PowerToys/issues/3814#issuecomment-776666200

Or something like suggested here:


cc: @crutkas , @jaimecbernardo

ghost commented 2 years ago

@htcfreek Excuse me . Today, when I wanted to work on this issue I realized that it's written in C++. So, I have to work on some other issues that are related to c#.

WouterVanGoey commented 2 years ago

Any progress on this topic? Is it possible with the current version to simply increment the value of number by one? I.e. img_1.jpg - img_216.jpg to img_2.jpg - img_217.jpg

polygonfuture commented 1 year ago

Seriously can we please get this added. Enumerating by a count variable is the most used feature of any renaming tool. Please. Its been over two years since this initial feature has been requested. What gives.

Frioo commented 1 year ago

Found this thread after using PowerRename for the first time. I thought this was one of the most default features for batch renaming. It'd be great to see this added.

m4heshd commented 1 year ago

Mind blown by knowing that this isn't a feature. I feel like this is the most fundamental requirement of batch-renaming.

oooseun commented 1 year ago

Came here looking for this feature too +10000

dragonshardz commented 1 year ago

+1, really want to be able to enumerate files without the () and have whatever leading zeroes I like, starting from any number I want.

scwall commented 1 year ago

I'm looking for exactly this feature

polygonfuture commented 1 year ago

@chrdavis @dedavis6797 @crutkas

Can we get an indication if this is on your radar at all?
It is a huge glaring missing feature to not be able to enumerate / incremental counter for files.

mbazaczek commented 1 year ago

powerrename is pretty great but without enumeration features it is useless in a lot of cases, +1

nikpushkarski commented 1 year ago

A little work around I've found is by renaming twice using RegExp. First add the required amount of prefix zeros, then remove them using RegExp

First iteration file-(\d+)\.png -> file-00$1.png

Second iteration file-(\d+)(\d{3})\.png -> file-$2.png (only keep the 3 digits in the second group)

Thx a lot for the idea, worked for me πŸ™πŸŽ‰ @locomoco28

mkings01 commented 1 year ago

Came here to ask for this feature. Would love to see it built in. I wanted it today to quickly rename a sequence of images so I could import into Photoshop.

I ended up using the existing bulk rename to get numbered filenames for each file including parentheses, then used the regex functionality to remove the parentheses.

I used the RegEx: (Filename )\((\d+)\)

and the substitution: $1$2

Regex example is here: https://regex101.com/r/cDRHNo/1

mkings01 commented 1 year ago

I just looked back at the previous comment from @nikpushkarski and saw he had the same idea as me, and then I realized Photoshop doesn't care about parentheses anyway. Ah well :)

DasPeter commented 1 year ago

I agree adding a new variable pattern to add as an argument in the replace section would be a solution that fixes all cases described here. Perhaps $N{x} where x is the start number would suffice.

SaintPeter commented 1 year ago

In a related note, I didn't even realize that enumeration was an option until I saw that it was implied. The discoverability on the "enumerate" icon is not very good. A checkbox like the "Use Regular Expressions" under the "Replace With" field might make it more discoverable.

Like this: image

Regardless, having a $COUNTER and/or more options would make this very helpful. In 99/100 use cases, I'm renumbering files.

alexklann commented 1 year ago

Regardless, having a $COUNTER and/or more options would make this very helpful. In 99/100 use cases, I'm renumbering files.

I agree! I would love to have this feature!

pbargiona commented 1 year ago

In my humble opinion, this is the most important feature pending to be added to PowerRename.

There are so many threads of confused people struggling and desisting to use PowerRename out of frustration for such a fundamental feature being so rudimentary and complicated, needing quite a lot of Regex witchery for a workaround.

Summary

This has been asked for so many times, as in #644, that was closed by enricogior in favor of solution-wise related #4011, that was closed in favor of unrelated #1002, that solved #4011's problem without touching #644.

This issue would be brought up again in still open #3814, that proposes an independent incrementing $counter that can be included anywhere in the "Replace with", which would solve your issue and allow for any separator (or none) to be used.

People also ask for this $counter to be offset-able (start from 15, for the same example in #5833), step-able (add or subtract more than1 or -1 for each iteration, as mentioned in #4929, with the added benefit of being "reversible", as asked for in #4129, assigned to crutkas), or configured to add zeroes on the left matching the highest enumerator number of digits (0001 to a 1456 enum, for example), as mentioned in #7402., which makes it easier to search/sort.

There are also #5538, #9583, #11251, #11890, #12329, #12417, #15056, Β§17522, #17730, #18225, #18628, #19702, #20246, #21916, #22879, #24401, #25763, and now this very topic.

Such a large number of requests, including from people not realizing Enumerate even exists, is proof enough that this feature is (1) highly requested, (2) very frustrating, (3) alienating potential users, and (4) worth of a redesign and more developer attention.

As for the workaround

I use Power Replace twice to add numbering to the beginning.

  1. First I simply add numbering with the current option and some random search and replace parameters (as, respectively, ^ and the separator, usually a dot and a space ". ").
  2. Then you have to use 2 capture groups like ptmrio suggested in #12329 using search for (.*) \(([0-9]+)\).jpg and replace with $2$1.jpg

You can theoretically add the enumerator wherever you want within the "Replace with", provided that you are very proficient in Regex or a bit stubborn.

Since I'm on the topic...

One thing that could improve enumeration is to allow sorting original files for criteria other than its original name. I argue that the original name is often the less useful criteria, since you do want to change it in the first place. (I still thank stefansjfw for this improvement over the previous egregious behavior, as described in #15269). This issue was also mentioned in #10960, #11145, #11640, #12802, #14288, #14417, and #15429.

File creation date is very useful and is already taken into consideration by PowerRename, but just to "Replace with", not to list the files or "Search for" them.

This too is workaroundable by using the tool several times.

  1. First to add the date with search for ^ replace with $YYYY$MM$DD$hh$mm$ss$fff (a feature that was added by user suggestion in #909, thanks waded).
  2. Apply and close.
  3. Open Power Rename again and do your actual renaming.
  4. If you want this obnoxious date gone, you can trim it with ^.{17} or .{17}$, depending if the date ended up at the beginning or the end (respectively) after your actual renaming.

However, file sizes, last modified, or other criteria, such as duplicates, mentioned in #12328, or date taken, in #25306, are completely unavailable.

On an ending note

I would love to help coding this solution, but this project has gone so far that, being a novice programmer, I don't feel that I can actually contribute with code, even if it seems as simple as changing a $ for a ^ for changing the default behavior from suffixing the enumeration to prefixing it.

If there are documents that can help getting people like us up to speed and contributing, I haven't been able to properly identify it.

I believe a possible starting point is checking out how the "Replace With" date functions above described were implemented, then checking the enumerator function and then trying to bake some code from these two sources.

Derpford commented 1 year ago

I'm going to once again mention that being able to swap the numbers out for letters would also be an excellent feature.

sandros94 commented 1 year ago

Using Adobe Bridge just to batch rename a group of files because of this...

siraxe commented 1 year ago

why is this still an issue that is ignored

ricklove commented 1 year ago

Workaround for padding zeroes:

yuyoyuppe commented 1 year ago

@ricklove As of 0.73, we've implemented proper zero padding support as well as some other features, see https://learn.microsoft.com/en-US/windows/powertoys/powerrename#enumerate-items

locomoco28 commented 1 year ago

I missed the news, great feature, thank you <3

jaimecbernardo commented 1 year ago

This issue has been worked on and released during the 0.73 Release project. Please update PowerToys to the latest. πŸ˜‰