Miscellaneous - Questions

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 8477
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 02 Aug 2019 23:12

Remove $2 from that line^^
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 02 Aug 2019 23:21

OMG! No way! I never mind it to remove it. Even didn't pay attention on it.
Thanks a lot.

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 16 Aug 2019 21:40

I believe this is maybe so easy but still trying unfortunately couldn't done it by myself.
I'd like to below code also could work for files, please.

Code: Select all

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $base = gpc($folder, "base", -2, 1);
        $newName = replace(regexreplace($base, "^(.*?)(_Male|_Female)(.*?$)", "$1$2"), "_", " ");
        renameitem($newName, $folder);
    }


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

Re: Miscellaneous - Questions

Post by highend » 16 Aug 2019 21:49

And removing the line with the check if it is a folder doesn't come to your mind? oO
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 16 Aug 2019 23:04

I didn't remove it vice versa I tried to add more lines for files. Thanks a lot. Seems works good.

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 18 Aug 2019 02:29

I would like to add '.' to this line but can't and I tried like this '.|_' unfortunately this doesn't work.

Code: Select all

foreach($folder, <get SelectedItemsPathNames |>, , "e") {
    $base = gpc($folder, "base", -2, 1);
    $newName = replace(regexreplace($base, "^(.*?)(.Male|.Female|_Male|_Female)(.*?$)", "$1"), ".|_", " ");
    renameitem($newName, $folder);
}
Real version:
Andrew.Smith65.JaneSmith69.Male.AJ6.1.000158-AWW

Expecting result:
Andrew Smith65 Jane Smith69

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

Re: Miscellaneous - Questions

Post by highend » 18 Aug 2019 05:15

Your regexreplace() is wrong (you're matching everthing in front of male/female, not only the dot) and inefficient as well
"^(.*?)(\.|_)(Male|Female)(.*?$)"
".|_"
Yeah, replace would search for that exact string. Does it exists (in your example)? Rather not.
Use replacelist() or another regexreplace()
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 18 Aug 2019 21:16

Unfortunately since first time I shared my AHK code lines. Today I need to share it again that it reached over 700 lines most of them I wrote by myself. Yes I remember that we already talked about this.

Image

So since you and @jupe explained well (I believe so) but I really can't write it by myself again and again. Unfortunately this is really so hard and even so bloody hard for me. Two times I tried to study that part of codes in .pdf documentation and it always open when I try to write some code.

I will try it again in next weekend. Thanks a lot.

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

Re: Miscellaneous - Questions

Post by highend » 19 Aug 2019 16:22

You can write up to 700 lines in AHK but you're not able to replace a single command in a XY script file?
Doesn't make sense to me
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: Miscellaneous - Questions

Post by MaxEnrik » 25 Aug 2019 03:17

This really looks like so easy and so simple but it took a lot of efforts and consumed a lot of times.
So far works good. Thanks a lot for your great explanations, I really highly appreciate that @highend

Hope nothing wrong in this code.

Code: Select all

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        $base = gpc($folder, "base", -2, 1);
        $newName = replacelist(regexreplace($base, "^(.*?)(\.|_)(Male|Female)(.*?$)", "$1"), ".,_", " ");
        renameitem($newName, $folder);
    }

Post Reply