Miscellaneous - Questions

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

Thank you for the key words! I'll do.

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

#1 Open - File name has . (dot). Causing to clear .extension.

Below code works fine until file name has .dot in it. And it causing to clear file .extension.
But of course I don't need to clear .extension of the file name.
Is there a chance to solve this issue?

(hope I explained well enough with my poor English)

Code: Select all

    foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected!") {
        $base = gpc($item, "base", 2, 0);
        $newName =  regexreplace($base, ".*\] (.*) \[.*", "$1");
        renameitem($newName, $item);
    }

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

Re: Miscellaneous - Questions

Post by highend »

What?

Your $base definition is nonsense, index and flags only apply to component, not to base

Something like

Code: Select all

$base    = regexreplace(gpc($item, "file"), "^(.+)\.[^.]+$", "$1");
?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

The problem still the same and stays.

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

Re: Miscellaneous - Questions

Post by highend »

Cool. Which problem exactly?
Show a real file name with path and how it should look like after your script has finished its work...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

These are original file names.

Code: Select all

[audio_3(967)] Soundtrack final __ promo [a.udo].mp3
[Video_A(0489)] DESIGN Title sequence Part.3 __ Edition Universe [a.mpv].mkv

These are what I expect.

Code: Select all

Soundtrack final __ promo.mp3
DESIGN Title sequence Part.3 __ Edition Universe.mkv

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

Re: Miscellaneous - Questions

Post by highend »

rename() isn't smart enough for this, so just give the file to rename its extension...

Code: Select all

    foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected!") {
        $base    = regexreplace(gpc($item, "file"), "^(.+)\.[^.]+$", "$1");
        $newName = regexreplace($base, ".*\] (.*) \[.*", "$1");
        renameitem($newName . "." . gpc($item, "ext"), $item);
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

It works perfect. Thank you!

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

I'd like to know differences of these two regex.

Code: Select all

    $newName = regexreplace($base, "\..*");
    $newName = regexreplace($base, "\.[^.]+?$");

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

Re: Miscellaneous - Questions

Post by highend »

The first would remove everything (including) the first dot and everything after it
while the second one would only remove the last dot with "something" behind it (which can't be a dot)
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

MaxEnrik
Posts: 90
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik »

Thank you for the explanations.

Post Reply