Rename Special

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
hawaii
Posts: 21
Joined: 18 May 2022 18:45

Rename Special

Post by hawaii »

I am having a heck of a time locating "rename special," I've been looking in the https://www.xyplorer.com/download/XYplorerHelp.pdf but unable to locate it within xyplorer. Now, now I see it's at the top of Right-Click file or file selection.

I'm trying to rename selected files with spaces (ie: "DATE_DAY at M-DD TIME") with underscores.

Using

Code: Select all

    $items = <get SelectedItemsNames>;
    end (!$items), "No item(s) selected, aborted!";

    $items = recase($items);
    $items = regexreplace($items, "( |-|_)+", "_");
    $new   = "";
    foreach($item, $items, <crlf>, "e") {
        $new .= regexreplace(gpc($item, "base"), "[^a-z0-9-]+", , 1) . "." . gpc($item, "ext") . <crlf>;
    }
    $new = trim($new, <crlf>, "R");
    if ($new != $items) {
        rename "l", $new, "p", , 64;
    }
This displays
Missing Seperator " > " between RegExpPattern and ReplaceWith!
Also if it's possible to generate a txt file stating what changed in the directory with original file format and new file formate time and date within the file?
ShareX settings
Subfolder pattern: %y%mo__
Upload/File naming: %y%mo%d-%mon2-W%wy_%h%mi%s%ms_%pn

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

Re: Rename Special

Post by highend »

You are pasting a full script into a simple pattern (one-line) edit box? oO

Menu - File - Rename Special - Search and Replace: > _
Done
Also if it's possible to generate a txt file stating what changed in the directory with original file format and new file formate time and date within the file?
Now you need to use a real script, the Rename Special doesn't provide logging to a .txt file
One of my scripts helped you out? Please donate via Paypal

hawaii
Posts: 21
Joined: 18 May 2022 18:45

Re: Rename Special

Post by hawaii »

highend wrote: 13 Aug 2025 04:03 You are pasting a full script into a simple pattern (one-line) edit box? oO

Menu - File - Rename Special - Search and Replace: > _
Done
Also if it's possible to generate a txt file stating what changed in the directory with original file format and new file formate time and date within the file?
Now you need to use a real script, the Rename Special doesn't provide logging to a .txt file
Captain DumbDumb here.

I see that now.

There is also an option for replace spaces to underscore.
20250812-August-W33_221928184_%pn.png
20250812-August-W33_221928184_%pn.png (24.13 KiB) Viewed 2686 times
Okay, I'll have to come up with a PS script for the rename and logging then.
ShareX settings
Subfolder pattern: %y%mo__
Upload/File naming: %y%mo%d-%mon2-W%wy_%h%mi%s%ms_%pn

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

Re: Rename Special

Post by highend »

Code: Select all

    $items = <get SelectedItemsNames>;
    end (!$items), "No item(s) selected, aborted!";
    setting "BackgroundFileOps", 0;

    $new = ""; $log = "";
    foreach($item, $items, <crlf>, "e") {
        $tmp = regexreplace($item, " ", "_");
        if ($tmp != $item) { $log .= $item . " => " . $tmp . <crlf>; }
        $new .= $tmp . <crlf>;
    }
    if (trim($new, <crlf>, "R") != $items) {
        rename "l", $new, "p", , 64;
        writefile("<curpath>\!changes.txt", $log, , "utf8");
        #485; // Refresh list
    }
One of my scripts helped you out? Please donate via Paypal

Post Reply