Last folder highlight

Features wanted...
ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Last folder highlight

Post by ivan »

Hello,

Having brainstormed a little, I came up with this suggestion:

Would it be possible to have an option so when clicking in the address bar only the last folder's name is highlighted?

Example:

The tree to the folder you're in looks like this: abc\def\ghi\jkl\ and you have a file in folder jkl that you want to rename to jkl (so the folder and the file in it are the same name, including upper and lower cases). Normally, first i'd click to select the whole tree and then click again and move the mouse to highlight the folder, press Ctrl + C and you know the rest. It would be much more convenient if by default it was possible to highlight the last folder (in this case it'd be jkl) on the very first click.

Thank you very much in advance!

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Even easier than that: you can use a script to do it for you!

Create a new UDC under "Run Script" and put this :

Code: Select all

regexreplace $name, <curitem>, "^.+\\([^\\]+?)\\[^\\]+?.*$", "$1";
 rename bat, $name;
Then, you can simply go into D:\abc\def\ghi\jkl and select a file, execute the script, and the file should be renamed to "jkl" ! (extension unaffected)
Proud XYplorer Fanatic

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

I take it the script has to be in the same folder as the file to be renamed? I actually already have a proggie that deals with renames on a massive scale. This is just a one file at a time job so I don't know how much of an alternative copying script over, running it and so on would be to a couple of clicks and drags but thank you nevertheless :D

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

ivan wrote:I take it the script has to be in the same folder as the file to be renamed?
No, go in menu "User|Manage Commands" and then under "Run Script" you create a new UDC with the given script.

Then, anytime you need to trigger it you just select the file to rename, and use menu "User|Run Script|[whatever name you gave it]" or, of course, you can assign a keyboard shortcut to it so that you only have to press the key of your choice to trigger it!
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:Even easier than that: you can use a script to do it for you!

Create a new UDC under "Run Script" and put this :

Code: Select all

regexreplace $name, <curitem>, "^.+\\([^\\]+?)\\[^\\]+?.*$", "$1";
 rename bat, $name;
Then, you can simply go into D:\abc\def\ghi\jkl and select a file, execute the script, and the file should be renamed to "jkl" ! (extension unaffected)
Nice one, jacky! :D I'll use that quite often...

PS: you should post it in Script Exchange...

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

weird, it didn't work for me :(

when i try do apply the UDC it renames the file to $name and not the folder's name :(

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

ivan wrote:weird, it didn't work for me :(

when i try do apply the UDC it renames the file to $name and not the folder's name :(
As jacky posted it, it's a multiline script. So take care that the 2nd line is indented.

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Yep, I've corrected it but now it adds "-01" to the end of the filename (exc extension) :(

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

ivan wrote:Yep, I've corrected it but now it adds "-01" to the end of the filename (exc extension) :(
That's automatic if a file of the name already exists! (avoids collision)

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Technically the file of the same name doesn't exist because of different case and extension ;)

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

ivan wrote:Technically the file of the same name doesn't exist because of different case and extension ;)
If the extension is different, no number is suffixed (there would be no collision).

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Post by ivan »

Well I'd hate to disappoint you but it seems that there is a collision happening. jacky said that in that script extension is unaffected so maybe it doesn't take it into account when renaming and this results in a collision? :?

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

ivan wrote:Well I'd hate to disappoint you but it seems that there is a collision happening. jacky said that in that script extension is unaffected so maybe it doesn't take it into account when renaming and this results in a collision? :?
But I just tried it and it works. :?

So what are your files in what folder? Show me the constellation that breaks my code! :wink:

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

admin wrote:But I just tried it and it works. :?
Me too! Worked just fine! But I had to go into editor mode to paste the copied script as it needed to be, however.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

admin
Site Admin
Posts: 66324
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

j_c_hallgren wrote:
admin wrote:But I just tried it and it works. :?
Me too! Worked just fine! But I had to go into editor mode to paste the copied script as it needed to be, however.
I see it's about time to add some file-based export/import for UDCs... :) ... will make it much easier to share such stuff.

Post Reply