renaming files based on similar names in other folder

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
ckp
Posts: 56
Joined: 07 Oct 2016 17:05

renaming files based on similar names in other folder

Post by ckp »

i know this is probably asking too much from xyplorer, but...

if i have folder 1 with file names like:
Bouncers (USA).zip

and folder 2 with similar names like:
Bouncers (blah)(U)-hello.chd

can all the files in folder 2 be named the same as folder 1 but not including the file extension?
so "Bouncers (blah)(U)-hello.chd" would be renamed to "Bouncers (USA).chd"

anything like that possible with the features in Xyplorer?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: renaming files based on similar names in other folder

Post by highend »

Sure, by scripting this

Open dual pane mode (Menu - Panes - [x] Dual Pane)
Navigate in the upper (or left) pane to the folder with the .zip files
Navigate in the lower (or right) pane to the folder with the .chd files
Activate the upper (or left) pane now!

Run the script (make sure you do this with test data first!)
It requires all files in both panes to have a 1:1 relationship
(first file in the inactive pane belongs to the first file in the active pane, etc.)
And if this isn't the case you should have posted better explanations of how exactly files are related
to each other...

Code: Select all

    if !(get("#800")) { status "No dual pane opened, aborted!", "8B4513", "stop"; end true; }
    $srcFiles    = listpane("a", , 1, <crlf>);
    $dstFiles    = listpane("i", , 1, <crlf>);
    $cntSrcFiles = gettoken($srcFiles, "count", <crlf>);
    if ($cntSrcFiles == 0 || $cntSrcFiles != gettoken($dstFiles, "count", <crlf>)) {
        status "Number of files is different in both panes, aborted!", "8B4513", "stop"; end true;
    }

    setting "BackgroundFileOps", 0;
    while ($i++ < $cntSrcFiles) {
        $baseSrcFile = gpc(gettoken($srcFiles, $i, <crlf>), "base");
        $dstFile     = gettoken($dstFiles, $i, <crlf>);
        $extDstFile  = gpc($dstFile, "ext");
        renameitem("$baseSrcFile.$extDstFile", $dstFile);
    }
One of my scripts helped you out? Please donate via Paypal

ckp
Posts: 56
Joined: 07 Oct 2016 17:05

Re: renaming files based on similar names in other folder

Post by ckp »

Thank you!

Post Reply