Using "search & replace" for cleaning multiple spaces?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 13333
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using "search & replace" for cleaning multiple spaces?

Post by highend »

Maybe start by reading the help file?

<get SelectedItemsPathNames>
What does that return?
All items separated by <crlf>!
Does the current foreach loop over <crlf>-separated files? Nope^^

$name = gettoken($file, -1, "\\");
Since when is "\\" a valid separator in Windows paths?
Apart from that, getting $name and $ext can be simplified by using getpathcomponent() / alias: gpc()

renameitem($file, $newName, "c");
Wrong order of arguments & what the heck should the "c" stand for?

Use step; / unstep; to check if things really do what they should...

and again: Scripting doesn't work if you don't consult the help file^^

Code: Select all

load "C:\\Users\\damie\\AppData\\Roaming\\XYplorer\\Scripts\\Replace dot with space.xys";
Again, "\\" is not a valid path separator^^
Regarding that path, quoted from the help file:
If the given filename does not contain an extension, XY will automatically add .XYS as its extension ("XYplorer Scriptfile"). So, to load the file MyScript.xys located in the application data folder, all you need to specify as parameter is MyScript: load "MyScript"
So a simple (if the script content were correct) load "Replace dot with space"; would have worked...
One of my scripts helped you out? Please donate via Paypal

Skettalee
Posts: 108
Joined: 06 May 2019 20:27

Re: Using "search & replace" for cleaning multiple spaces?

Post by Skettalee »

Im sorry i know you might find it hard to believe but I have read the help file and i frequent the message board often and do think im reading everything I just have an issue retaining information. I have both had a brain surgery in my life for a subdural haematoma and also have severe ADHD and those are the only things I can think would be my issues with reading and my problems with getting things done that I read. Im sorry i dont seem to retain much in but I am trying i swear. And as to my script being completely wrong Its because I tried to get Chat GPT to help me with scripting and I see that Chat GPT is no help. I couldn't figure it out myself by reading through the message board and other pages about scripting that yall may have. Is there a single document or webpage that lists all the commands in scripting, what it does, and how to use them that I can supply to chatgpt so it can better help me with this? Again I am sorry to cause any trouble with any of y'all.

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

Re: Using "search & replace" for cleaning multiple spaces?

Post by highend »

The help file has a scripting section. With all the rules, commands, functions and belonging examples

If that helps an AI to spit out valid code? I don't see a lot of I in AI...

Proper code for the task at hand would have looked like this:

Code: Select all

    foreach($file, <get SelectedItemsPathNames>, <crlf>, "e") {
        $base    = gpc($file, "base");
        $ext     = gpc($file, "ext");
        $newBase = replace($base, ".", " ");
        if ($base == $newBase) { continue; }
        if ($ext) { $newName = $newBase . "." . $ext; }
        else      { $newName = $newBase; }
        renameitem($newName, $file);
    }
One of my scripts helped you out? Please donate via Paypal

Skettalee
Posts: 108
Joined: 06 May 2019 20:27

Re: Using "search & replace" for cleaning multiple spaces?

Post by Skettalee »

Thank you so much, that actually worked right away. Yeah I know I thought I included the help file i found for xyplorer
is the XYplorer.chm the actual file? I know I usually just press F1 from inside xyplorer but I noticed that if i try to run that file from explorer then it opens what looks like the help file window but with no contents in it. that file is only 1.25 mb's maybe making me think that it doesn't actually have all the stuff the help file has in it. Thank you so much for the script though!

phred
Posts: 244
Joined: 26 Dec 2021 02:10
Location: Running Windows 10 at 100% from Boston USA

Re: Using "search & replace" for cleaning multiple spaces?

Post by phred »

The latest help pdf can always be found here
All 867 pages of it.

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

Re: Using "search & replace" for cleaning multiple spaces?

Post by highend »

the help file window but with no contents in it
You need to unblock the .chm (google is your friend)
One of my scripts helped you out? Please donate via Paypal

Skettalee
Posts: 108
Joined: 06 May 2019 20:27

Re: Using "search & replace" for cleaning multiple spaces?

Post by Skettalee »

I have looked on google for unblock chm, and it just gave me what i already know about files being blocked if you download them off the net, maybe I am going in the wrong direction though? I have already checked if that file is being blocked by anything as well as giving my user name full permissions to use the file, it still shows nothing in it.
I noticed the previous message about the PDF version of the help file and have downloaded that so thank you!

RalphM
Posts: 1935
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Using "search & replace" for cleaning multiple spaces?

Post by RalphM »

Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

Skettalee
Posts: 108
Joined: 06 May 2019 20:27

Re: Using "search & replace" for cleaning multiple spaces?

Post by Skettalee »

Yes i am well aware of that blocked feature but I have checked my xyplorer folder, the CFM file and all other files there, none of them are set as blocked so they dont have any block setting in the properties, I have even went further using Winareo Tweaker to make sure that it wasn't being blocked by anything

Skettalee
Posts: 108
Joined: 06 May 2019 20:27

Re: Using "search & replace" for cleaning multiple spaces?

Post by Skettalee »

I will add that I have downloaded the xyplorer portable version from some site and extracted and found the same help file but that one I was able to see the contents of. I tried copying that file to the program files x86 directory xyplorer but when executed there it went back to being black, I even set full control for my user name in that one and the appdata xyplorer folders to see if it was a permission issue but it never was able to run from inside its original directory.

Post Reply