I'm trying to replicate the Search and Replace functionality of './ ' (without quotes). This replaces all of the '.' characters in a file except for the one before the file extension. I've been unsuccessful using the replace() function as shown below.
$var_file = "<curname>";
$x = replace($var_file, '.', [replacement=" "], [matchcase=0], [start=1], [count=-1]);
How to script Search and Replace functionality?
Re: How to script Search and Replace functionality?
What?This replaces all of the '.' characters in a file except for the one before the file extension
This would replace all dots, no exception^^
Code: Select all
$var_file = <curbase>;
$x = replace($var_file, ".", " ");
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
Re: How to script Search and Replace functionality?
I'm having difficulty executing that replace() function. When I execute it nothing happens. Like it's not even there. I tried it with the Scripting -> Run Script menu item, and also placed it in the left click section of a button. Nothing happens in either case. So, I tried adding all of those X's to generate a syntax error, and still nothing. I believe the spacing and indentation are correct. I made sure there were no extraneous whitespace characters below the code. Also, I just updated XYplorer to the latest version for good measure. Any idea why that code is not executing at all?highend wrote: ↑04 Apr 2022 18:23What?This replaces all of the '.' characters in a file except for the one before the file extension
This would replace all dots, no exception^^
Code: Select all
$var_file = <curbase>; $x = replace($var_file, ".", " ");
Code: Select all
$var_file = <curbase>;
XXXXXXXXXX
$x = replace($var_file, ".", " ");
Re: How to script Search and Replace functionality?
The code is executing just fine. I have no clue why you think that it would actually rename a file though. Do you see any command like rename / renameitem in your code? I don't...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
Re: How to script Search and Replace functionality?
Not necessarily. If you are not sure, what your script is doing, there is a
step
command...One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
Re: How to script Search and Replace functionality?
Hey bud did you end up figuring out the code. I think I have been trying to do the same thing. I wanted a one hand mouse button click to first turn decimals into one space and not the .ext one. Im still having a hard time doing any dang coding even though i spent most of my time in front of it. My adhd screws me up there, so if you figured that one out id love to get that code myself!
Re: How to script Search and Replace functionality?
I regularly rename files by replacing a dot with a space, excluding the extension. This is what I use:
Code: Select all
end(getinfo("CountSelected") < 1), "Nothing selected!";
rename s, "./ ";
Windows 10 Pro 22H2