Tweak to define Multiple Item Rename Mode

Features wanted...
Post Reply
TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Tweak to define Multiple Item Rename Mode

Post by TheQwerty »

It's nice that if you execute Rename with multiple items selected XY uses Batch Rename, but I'd like to see a way to change which mode is used.

I hardly ever use Batch Rename so it would be more useful (for me) if this would use RegExp, as it would eliminate my need for multiple CKSs or having to start the rename differently.

I think a simple tweak which could use the same values as the Rename script command ("b|r|s|k|e") would suffice.

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

Re: Tweak to define Multiple Item Rename Mode

Post by jacky »

Or you could always do it yourself using a (little) script! ;)

Code: Select all

	// Save Clipboard
	set $clipboard, <clipboard>;
	// Copy Name(s)
	#102;
	set $list, <clipboard>;
	// get last 2 chars, crlf means more than one item
	substr $fix, $list, -2;
	// nothing at all: we'll add 0 (just like when crlf)
	regexreplace $fix, $fix, "^$", ":";
	// turn crlf into ":"
	regexreplace $fix, $fix, <crlf>, ":";
	// if everything but ":" it means no crlf (and no empty), so it was one single name, so we'll add 1
	regexreplace $fix, $fix, "^[^:]+$", "1";
	// otherwise we'll add 0
	regexreplace $fix, $fix, "^:$", "0";
	//
	// turn all crlf in ":"
	regexreplace $list, $list, <crlf>, ":";
	// remove everything but ":"
	regexreplace $list, $list, "[^:]", "";
	// thus we get the number of ":" = crlf = items
	strlen $nb, $list;
	// adding the fix
	incr $nb, $nb, $fix;
	// Restore Clipboard
	copytext $clipboard;
	// nice & clean
	status "Renaming...";
	// do appropriate rename operation
	regexreplace $next, $nb, "^(0|1)$", "#172;";
	regexreplace $next, $next, "^((?!^#172;$).)*$", "#122;";
	load $next,,s;
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tweak to define Multiple Item Rename Mode

Post by TheQwerty »

Other than there's no way to execute a script in all the places that rename can be called. (File->Rename, Context Menu->Rename)

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

Re: Tweak to define Multiple Item Rename Mode

Post by jacky »

TheQwerty wrote:Other than there's no way to execute a script in all the places that rename can be called. (File->Rename, Context Menu->Rename)
Well, no, but since you mentioned multiple KS I thought you used KS to trigger your Rename operations, and in such a case a script works just as fine.

For menus you're sent to the User menu indeed, and for the context menu we'll have to wait for "onEvent Actions" to define our own context menus (which will be much faster than items' ctxt menu, I can't stand those things, can be so freaking slow, especially when I'm n a hurry... That's why I never use them.). Meanwhile, it's KS, Catalog items, POM, or you could also "hijack" the Tree's context menu and call the script from Favorites... ;)
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tweak to define Multiple Item Rename Mode

Post by TheQwerty »

jacky wrote:
TheQwerty wrote:Other than there's no way to execute a script in all the places that rename can be called. (File->Rename, Context Menu->Rename)
Well, no, but since you mentioned multiple KS I thought you used KS to trigger your Rename operations, and in such a case a script works just as fine.

For menus you're sent to the User menu indeed, and for the context menu we'll have to wait for "onEvent Actions" to define our own context menus (which will be much faster than items' ctxt menu, I can't stand those things, can be so freaking slow, especially when I'm n a hurry... That's why I never use them.). Meanwhile, it's KS, Catalog items, POM, or you could also "hijack" the Tree's context menu and call the script from Favorites... ;)
Yes, there's a ton of ways but if I have to remember to do something differently that defeats the purpose of the request. :P Allowing the user to change which mode is used here, would be a lot easier than implementing all those other things and making the user script it all.

Besides what would be better with scripting is if the "onEvent Actions" would then have "BeforeRename" and "AfterRename" actions, with a way to abort the event. Then I could use a very modified version of your script (hopefully we'll have actual logic before onEvent Actions), to do the same thing.

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

Re: Tweak to define Multiple Item Rename Mode

Post by jacky »

TheQwerty wrote:Yes, there's a ton of ways but if I have to remember to do something differently that defeats the purpose of the request.
Yeah, but at first I thought you used F2 to rename, and some other KS to RegExp Rename, hence the script that, assign to F2, is th eonly one KS you'd need to use. Of course, if you don't want to only use KS that doesn't apply anymore... ;)
TheQwerty wrote:hopefully we'll have actual logic before onEvent Actions
I so disagree on that one 8) I mean sure scripting 2.0 with things like conditions, loops, etc will be a great thing, but I for one can't wait for onEvent Actions first. Because it can be useful already with scripting as it is now, plus we've got ways to workaround and use conditions/loops today, but not for onEvent stuff, for this one we have to wait for it to be implemented! (And I can't wait :mrgreen:)
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tweak to define Multiple Item Rename Mode

Post by TheQwerty »

Thanks for adding this Don!

I appreciate not having to think before starting my renaming. :lol:

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

Re: Tweak to define Multiple Item Rename Mode

Post by admin »

TheQwerty wrote:Thanks for adding this Don!

I appreciate not having to think before starting my renaming. :lol:
That was my goal! XYplorer -- skip thinking, just do it.

Post Reply