Page 1 of 1

Rename Special

Posted: 13 Aug 2025 01:25
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?

Re: Rename Special

Posted: 13 Aug 2025 04:03
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

Re: Rename Special

Posted: 13 Aug 2025 05:24
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 2694 times
Okay, I'll have to come up with a PS script for the rename and logging then.

Re: Rename Special

Posted: 13 Aug 2025 09:37
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
    }