I've noticed something fishy with the order of renaming.
I've created a button to handle renaming and versioning my .SQL files for deployment order. Basically, I name the file something meaningful, put an integer in front of its name, select as many as I want to rename, and then let the hell break loose with the button. It renames the file by adding a "wider" integer (usually in the thousands) to the front and then a few things more. The problem emerged when I had to handle many files and changed the default ordering to 1: Type ascending, 2: Extension ascending, and 3: Name descending. For some folders, there might be 4th and 5th order rules, for others only those 3. The first two don't do much as there are always only .SQL files there (or at least selected).
Now, applying the numbering rename preset to the selection obviously wouldn't work anymore as it would rename the files in the reverse order, meaning the file I'd like to deploy first would get deployed the last instead. Not good. So I created another button and changed its function from
@set start = {dlgstringS|Start numbering at|1001}
rename PRESET="Add numbering" NUMBER {$start}
// the "few things more" part removed for the sake of simplicity
to
@set start = {dlgstringS|Start numbering at|1001}
@confirm Reverse order
Set SORTREVERSE=Toggle
@confirm Apply Rename Preset
rename PRESET="Add numbering" NUMBER {$start}
@confirm Restore order
Set SORTREVERSE=Toggle
At first, it was without the @confirms, I added those later so that I could watch what is happening (definitely not what I expected). If I ran each step separately (eg. from Opus CLI or using separate buttons), the results were correct. But when running it as a single batch using a single button, the ordering of the rename did not change as it should.
So, after clicking the second button, the files are still renamed as if their order wasn't reversed before renaming.
I've checked the description for SORTREVERSE and it says:
Reverses the sort order in the current file display. If the list is only sorted by one column, the direction of that column sort is reversed. If multiple columns are selected for sorting, their directions are not altered but the overall result is reversed as the final step in the sorting.
And indeed, when running it step by step, seemingly the order stayed as it was, order indicator was still showing arrow 1 up on Type, arrow 2 up on Ext, and arrow 3 down on Name. According to SORTREVERSE description that made sense: it really didn't change the order, it only reversed the result, so I thought the new ordering was only temporary. Except when I used the first button on this supposedly temporary ordered set of files, it yielded the expected (or unexpected in this case) results of renaming the files in the correct order.
It seems that when I click the button, the order of files the Rename function is working with is the one that was in effect at the time of the button being clicked and not the order which was in effect when the Rename function was executed, that is, the Rename function completely disregards the preceding changes in the order of the files. Check this short video here.
- Could you confirm this being the case here?
- If it is, is it a bug or is it intentional?
- If it's intentional, is there a way to achieve my goal using a single button with multiple commands instead of moving each command/function to a separate button and having to click them in a certain order (which makes it not-so-quick-at-all-anymore)?