Option to auto-replace illegal chars on input dialogs

Features wanted...
Post Reply
1024mb
Posts: 205
Joined: 14 Dec 2018 23:26

Option to auto-replace illegal chars on input dialogs

Post by 1024mb »

There have been times where I've pasted some text that has illegal characters and I don't notice them or simply forget about them but upon clicking OK the script fails because I use that input as a filename and Windows doesn't accept certain chars.

Could you add an option so XYplorer auto replaces on paste the illegal characters or just don't accept them showing an error?

Delphine
Posts: 47
Joined: 24 Jun 2019 18:37

Re: Option to auto-replace illegal chars on input dialogs

Post by Delphine »

What's an "illegal" character ?

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Option to auto-replace illegal chars on input dialogs

Post by Horst »

And how should XY know what purpose your input has in advance ?
If you make such errors often you can add a routine to your scripts to make a check according to some rules.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

1024mb
Posts: 205
Joined: 14 Dec 2018 23:26

Re: Option to auto-replace illegal chars on input dialogs

Post by 1024mb »

Delphine wrote: 23 May 2021 18:36 What's an "illegal" character ?
In Windows are: ":", """ (quote), "?", "*", "\", "/", "<", ">" and "|" . Also you can't name "con", "com#" or "nul" any file or folder.
Horst wrote: 23 May 2021 18:41 And how should XY know what purpose your input has in advance ?
If you make such errors often you can add a routine to your scripts to make a check according to some rules.
I was thinking by implementing a name input dialog command or adding a param so we can set a dialog to be like that.

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

Re: Option to auto-replace illegal chars on input dialogs

Post by highend »

You could just do it with a:

Code: Select all

    $input = '"a<>b|*c?d\e/f'; // You'd be using an input() here... 
    $input = regexreplace($input, "(^(con|com#|nul)$|[""?*\\/<>|])", "_");
One of my scripts helped you out? Please donate via Paypal

1024mb
Posts: 205
Joined: 14 Dec 2018 23:26

Re: Option to auto-replace illegal chars on input dialogs

Post by 1024mb »

highend wrote: 23 May 2021 19:48 You could just do it with a:

Code: Select all

    $input = '"a<>b|*c?d\e/f'; // You'd be using an input() here... 
    $input = regexreplace($input, "(^(con|com#|nul)$|[""?*\\/<>|])", "_");
I will try that, thank you!

Post Reply