Rename Special - Rename from Clipboard ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
VeeGee

Rename Special - Rename from Clipboard ?

Post by VeeGee »

Good afternoon all,
Is there any way to rename selected files within a folder so it has the same name as the folder (and keep the existing extension) ? For my current project, this how I am currently doing it :
1. Browse into the folder / right-click on the folder (on the breadcrumb bar) and select Copy Name (to get the folder name on the clipboard)
2. Single-slow-click or F2 the file / right-click Paste / click off of the file
3. Repeat for any other file in the folder
When I'm done, the file(s) have the same name as the folder and the extension is left alone.

Checking if there is an option to either 1) rename the selected files based on the clipboard text (the folder name in this example) or 2) select any number of files / right-click / Rename Special and have something like "Rename to Match Folder".

EDIT: Looking at a script posted by highend, I am going to use this as a base and see if I can get it working ! This version moves selected files into folders matching their name. I should be able to figure this out now via scripting.

Code: Select all

    foreach($item, <get SelectedItemsPathNames |>) {
        $base   = gpc($item, "base");
        $ext    = gpc($item, "ext");
        $folder = $base;
        moveto "<curpath>\$folder", $item, , 2;
    }

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename Special - Rename from Clipboard ?

Post by highend »

Or you do it in a faster way (no loop needed) e.g. via:

Code: Select all

rename "l", replace(regexreplace(<get SelectedItemsNames <crlf>>, "^(.*\.)", gpc(<curpath>, "component", -1) . "."), <crlf>, "|");
Another pro:
You can undo the renaming with one step from the action log if necessary
One of my scripts helped you out? Please donate via Paypal

VeeGee

Re: Rename Special - Rename from Clipboard ?

Post by VeeGee »

Dang, that is perfect ! Thanks.
I had come up with this, clunky but working - I'll stick to yours :biggrin:

Code: Select all

	foreach($item, <get SelectedItemsPathNames |>) {
		$folder = gpc("<curitem>", "parent", , 0);
		renameitem($folder, $item);
	}
Took a bit of back and forth from the manual to testing. Such a powerful piece of software.

Post Reply